Reputation: 17831
I want to create this TableLayoutPanel (C# in WinForms - programatically created at runtime!)
---------------------------------------------------------------------
| 01.01.2010 01:00 | 01.01.2010 01:00 | 01.01.2010 01:00 |
---------------------------------------------------------------------
| Some text | More | And | Final text |
| (Multilined) | multilined | more text | Multiple lines,|
| | text | | too |
---------------------------------------------------------------------
But currently it lookes more like this
---------------------------------------------------------------------
| 01.01.2010 01:00 | 01.01.2010 01:00 | 01.01.2010 01:00 |
---------------------------------------------------------------------
| Some text | More | And | Final text |
| (Multilined) | multilined | more text | Multiple lines, |
| | text | | too |
---------------------------------------------------------------------
How can I achieve the layout above - meaning, the columns' width is adjusted to fit the whole table equally - but if a column needs more space, it can resize itself to the preferred size?
Upvotes: 1
Views: 1830
Reputation: 704
I realize this question is old, but it doesn't seam to be properly answered. Look at the ColumnStyles
property, just shooting from the hip it would look something like this:
TableLayoutPanel1.ColumnStyles(0) = New ColumnStyle(SizeType.Percent, 100/TableLayoutPanel1.ColumnStyles.Count)
Upvotes: 0
Reputation: 941397
Set the column Size Type to Percent instead of Absolute. Select the panel, click the little arrow glyph in the upper right corner, Edit Rows and Columns.
Upvotes: 2