Alejandro del Río
Alejandro del Río

Reputation: 4046

How to rezise all panels within a winform without overlap

I have a form with panels. I want all the panels to be resized when the form resizes but without overlap between them. Like this

Panels resizing

I have tried to put this anchors on the panels: Top, Bottom, Left, Right. But the result is like this

enter image description here

Obviously this is wrong. So, is there some way to configure the panel properties in order to behave like I propose?

Upvotes: 1

Views: 57

Answers (1)

erdomke
erdomke

Reputation: 5245

To expand upon @Reza's comment, what you want to do is place a TableLayoutPanel Control on the form. This control will either be anchored on all sides (top, bottom, left, and right) or set to Dock = Fill. You would want to add four columns to the TableLayoutPanel and tweak the sizing options (e.g. setting each column width to 25%). Then you would place your panels in the different cells of the TableLayoutPanel. This should give you the sizing behavior that you would like.

Upvotes: 1

Related Questions