I am using a tableLayoutPanel
which consist of two rows. In first row I want two columns,
and in second row I only need one column. How can I do this?
Asked
Active
Viewed 3.5k times
27
2 Answers
52
With the designer: put a control in the 2nd row and set its ColumnSpan property to 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);
}

Hans Passant
- 922,412
- 146
- 1,693
- 2,536
4
If you are on visual studio, just set the ColumnSpan property of control you want to put in row 2 to '2' and it will take care of that.

Haider7
- 459
- 4
- 3