Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In TableLayoutPanel if Dock = Fill and AutoSize = true then last column/row occupy all remaining space

Tags:

winforms

In TableLayoutPanel if we set AutoSize = true and Dock = fill then last column/row will occupy all remaining space. How to set it to required height (row) and width (column)?

like image 605
gauravghodnadikar Avatar asked Jan 13 '10 05:01

gauravghodnadikar


3 Answers

I just added an additional last row and set its size to Absolute and 0 pixel. This worked for me.

like image 191
ctusch Avatar answered Nov 07 '22 14:11

ctusch


To complete the answer of @user232986 that helped me solve my issue. This is code for VB.NET In the designer I selected for

  • Row1: AutoSize (Containing data like a Label for example)
  • Row2: AutoSize (Containing data like a Panel for example)
  • Row3: Percent 100% (This is the last row containing data)
  • Row4: Absolute 0 (Add a dummy row)

Then in my code I changed this settings and it worked like a charm.

Me.tableLay.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
Me.tableLay.AutoSize = True
Me.tableLay.Dock = DockStyle.Fill

I only have a single column which is set to Percent 100,00%.

like image 2
Matthis Kohli Avatar answered Nov 07 '22 14:11

Matthis Kohli


You should add TableLayoutPanel as tbl1 with two rows and two columns. Then set dock = fill autoscroll = true and set width for 1st row to autosize and for the second absolute 0.00 F.

Do the same for column 1 and 2. Now add actual TableLayoutPanel in 1st rows 1st column.

like image 1
gauravghodnadikar Avatar answered Nov 07 '22 14:11

gauravghodnadikar