Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TableLayoutPanel Last Row Size Too Big

My application uses a TableLayoutPanel that resides within a TabPage.

If the number of items I add is relatively small (i.e. it doesn't "fill up" the whole tab page) then the last row's height is stretched. Here is a screenshot of what's happening:

Table Layout Panel Last Row

I have tried to change the properties of the table to Autosize, GrowAndShrink, etc. but nothing seems to stop this from happening.

Here are my current settings for the layout properties of the table:

Table Layout Panel Layout Properties

How can I get the last row to be the same size as the other rows?

Thanks

like image 747
Jan Tacci Avatar asked Jun 30 '13 19:06

Jan Tacci


2 Answers

Using the dock property solves the last row height problem, but creates another by changing the table width to match the container width (100%). I wanted the height in the last row to be correct but I do not want the forced 100% width.

Instead of using the Dock property, I used:

AutoSizeMode = AutoSizeMode.GrowAndShrink

That made the autosize work correctly on the last row and column.

like image 158
Vincent James Avatar answered Sep 22 '22 04:09

Vincent James


I just had very similar problem. Filling TableLayoutPanel programatically (with autoscroll) and the last row was too high. Dock work-around was not suitable for me.

Fixed by adding empty Label as the last row. It "occupies" the last row, but is not visible. Enough for me.

like image 24
DangeMask Avatar answered Sep 20 '22 04:09

DangeMask