Diego
Diego

Reputation: 16714

.NET WinForms Anchor Property

I have a form that has a panel in it. I've set the panel anchor and it works great, when I resize the form the panels height is increased.

The problem is: I've got several group boxes in the panel, and when the panel's height is increased, the group box vertical spacing should be increased equally.

How can I do that?

Upvotes: 0

Views: 926

Answers (2)

Diego
Diego

Reputation: 16714

I've just seen this question from a long time ago. The form I was talking about end up with a different interface, but I've recently done something very similar and I did it like this:

  • TableLayoutPanel with the Anchor set to be increased on the form resize (top and bottom for only the height or top, right, bottom and left for height and width like my case).
  • All the rows should have a size mode "percentage" and the right percentage (i. e. 10 rows, 10%).
  • The boxes inside the TableLayoutPanel should not be docked to fill mode. And should have the Anchor set to left and right. This way they will always be in vertical centered in the row from the TableLayoutPanel and will increase their height to the maximum allowed by the row.

Upvotes: -1

Pete
Pete

Reputation: 11495

Use a TableLayoutPanel and make sure the rows in it are all set to a size mode of "AutoSize". Next, make sure that your boxes you place in the table have a the "Dock" property set to one of the fill modes.

Upvotes: 6

Related Questions