Question

I created a TableLayoutPanel and I would like to reduce the width of one of the columns. Is TableLayoutPanel.ColumnStyles the way to go? I find the MSDN documentation confusing. How do I apply tableLayoutPanel.ColumnStyle?

self.tableLayoutPanel.Location = Point(20,80)
self.tableLayoutPanel.Size = Size(200,50)
self.tableLayoutPanel.RowCount = 2
self.tableLayoutPanel.ColumnCount = 6
self.tableLayoutPanel.AutoSize = True
self.tableLayoutPanel.AutoScroll = False
self.tableLayoutPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset
#self.tableLayoutPanel.ColumnStyles = ??
Was it helpful?

Solution

You need to add the column style and row style to each column and row:

Example:

For i As Integer = 0 To self.tableLayoutPanel.ColumnCount - 1
  self.tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 64))
Next
For i As Integer = 0 To self.tableLayoutPanel.RowCount - 1
  self.tableLayoutPanel.RowStyles.Add(New RowStyle(SizeType.Absolute, 24))
Next
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top