TableLayoutPanel Last row size is too large

My application uses the TableLayoutPanel, which is inside the TabPage.

If the number of elements that I add is relatively small (that is, it does not "fill" the entire bookmark), then the last line height is stretched. Here is a screenshot of what is happening:

Table Layout Panel Last Row

I tried changing the properties of the table to Autosize, GrowAndShrink, etc., but nothing prevents this.

Here are my current table layout properties:

Table Layout Panel Layout Properties

How can I make the last line be the same size as the other lines?

thanks

+6
source share
4 answers

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

+4
source

I had a very similar problem. TableLayoutPanel programmatically (with autoscrolling), and the last row was too high. Dock desktop is not suitable for me.

Fixed by adding an empty Label as the last line. It "takes" the last line, but is not displayed. Enough for me.

+3
source

I had a similar problem where the last line was always too high in TLP with more lines than it could match using AutoScroll.

The solution was to disable AutoScroll, set the line sizes from the TLP string collection, and then turn AutoScroll back on.

+2
source

Using the dock property solves the problem with the height of the last row, but creates another one by changing the width of the table to fit the width of the container (100%). I wanted the height in the last line to be correct, but I don't want the forced 100% width.

Instead of using the Dock property, I used:

 AutoSizeMode = AutoSizeMode.GrowAndShrink 

This made autosize work correctly in the last row and column.

+2
source

Source: https://habr.com/ru/post/948433/


All Articles