Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a columnspan in tableLayoutPanel

Tags:

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?

like image 768
Nighil Avatar asked Mar 01 '11 07:03

Nighil


1 Answers

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);     } 
like image 131
Hans Passant Avatar answered Sep 17 '22 12:09

Hans Passant