Question 3 Panel strech problem on form size change

kpgraci

Active member
Joined
Feb 21, 2011
Messages
30
Location
New Orleans
Programming Experience
10+
Hi all,

I thought this would be easy but for some reason it's giving me a rough time. :nonchalance:

I have a windows form with three equal size panels on it. Each panel takes up about 1/3 of the window width, less some inter-panel spacing.

The effect I want is if the user stretches or shrinks the form the panels maintain their relative 1/3 width and spacing, similar to how divs on an html page would size as the browser window is sized.

So I anchored the left panel to left, top and bottom, the center panel to top and bottom, and the right panel to top, bottom and right.

This works fine in keeping the left and right panel anchored to their respective sides, and all panels now stretch with a form height change.

So in form resize I adjust the width of each panel to form.width/3. As expected this is close but does not account for the inter-panel margins I want to preserve and the form border width.

I played around with various constants and noting I do gives me the desired effect.

I'm sure there is a pretty straight forward solution to this but I can't seem to find it.

Ideas?

thx
kpg
 
My first thought would be to use a TableLayoutPanel, dock filled to the form, with one row, and three columns, all set at 33%. You can then put a panel in each cell, dock filling each panel into the cell.
 
Back
Top