[英]How to set a columnspan in tableLayoutPanel
I am using a tableLayoutPanel
which consist of two rows. 我正在使用
tableLayoutPanel
,它由两行组成。 In first row I want two columns, and in second row I only need one column. 在第一行我想要两列,在第二行我只需要一列。 How can I do this?
我怎样才能做到这一点?
With the designer: put a control in the 2nd row and set its ColumnSpan property to 2. 使用设计器:将控件放在第2行并将其ColumnSpan属性设置为2。
In code: 在代码中:
public Form1() {
InitializeComponent();
var button = new Button();
button.Dock = DockStyle.Fill;
tableLayoutPanel1.Controls.Add(button);
tableLayoutPanel1.SetCellPosition(button, new TableLayoutPanelCellPosition(0, 1));
tableLayoutPanel1.SetColumnSpan(button, 2);
}
如果你在visual studio上,只需将你想要放在第2行的控件的ColumnSpan属性设置为' 2 ',它就会处理它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.