Question

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

Was it helpful?

Solution 3

Based on your design and your requirements I suggest you to make Dock property of TableLayoutPanel to top.

OTHER TIPS

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.

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.

I had a similar problem where the last row was always too high in a TLP with more rows than could fit, using AutoScroll.

The solution was to turn AutoScroll off, set the row sizes from the TLP Rows collection, then turn AutoScroll back on again.

1 pixel is the minimum unit! eg: 10 rows to average container height , if TableLayoutPanel height is 200, it's perfect! But if the TableLayoutPanel height is 199 . the computer unable to spilt one pixel; so, the every row's height must be 19 while the last row height is 19+(199 - 19*10)= 28; As a result: the last row is 10 heighter than other row. What we need to do is avoid set the TableLayoutPanel height unabe to average.or we need to change the TableLayputPanel height !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top