user682487
user682487

Reputation:

C# .NET TableLayoutPanel's last column gets stretched

I am creating a TableLayoutPanel programmatically. It has 2 rows. The amount of columns are added by the user.

It's also possible to remove 1 column at a time.

But whenever i do, and shifting all controls 1 column back to close the empty column, the last column get's stretched to fill up the space that's left over as if it had autosize instead of an absolute width.

The problem is: I want my last column to be as wide as the rest, and i don't know how.

Thanks for reading, Danny

Upvotes: 3

Views: 3002

Answers (2)

invizion
invizion

Reputation: 93

I too was having this same issue however my last ROWS height was abnormally larger than the others. The solution provided by author worked for me as well, which is to add your TableLayoutPanel into a Panel then modify the properties of both as such:

Panel:

Autoscroll = true;
AutoSize = false;

TableLayoutPanel:

AutoScroll = false;
AutoSize = true;

Upvotes: 4

user682487
user682487

Reputation:

It seems i have been able to solve the problem myself.

My solution:

I have put the TableLayoutPanel inside a Panel, whereby the following parameters have been set:

Panel:

Autoscroll = true;

AutoSize = false;

Dock = Right;

TableLayoutPanel:

AutoScroll = false;

AutoSize = true;

Dock = Left;

When this setup is set, you can add/remove as much columns as you like WITHOUT having the last column obnoxiously filling up the rest of the TableLayoutPanel.

Upvotes: 3

Related Questions