Search code examples
c#.netwinformstablelayoutpanel

Different cell sizes in a Windows Forms TableLayoutPanel


In Windows Forms, how do I make it so that the TableLayoutPanel will contain different cell sizes (either for rows and/or columns)?

For example: row 1 might have only 1 cell, row 2 might have 5, row 3 might have 5 again, but with different column sizes.


Solution

  • You cannot choose the number of columns per individual row, nor vice versa. What you can do, however, is to have controls on the TableLayoutPanel span across several cells in either direction.

    Therefore, choose the required number of rows and columns & their sizes to set up the desired "grid" structure, then set the RowSpan and ColumnSpan properties on individual controls placed in the panel cells to combine these cells to larger ones. (These "foreign" properties get attached by the panel to controls placed in its cells).