tags:

views:

91

answers:

2

Hello,

I have a dialog with column down the right side filled with buttons. The dialog is built with Windows Forms. I have a mockup at the following link:original dialog (I would have included it but apparently i'm not allowed to use image tags)

I would like for the buttons in the right column to resize themselves to fill the remaining vertical space when the dialog resizes. It doesn't particularly matter to me whether or not buttons simply increase in size or whether the buttons remain the same size while the gaps between them increase. I'm simply want the buttons to go from the top to the bottom. (I have a mockup for this as well but apparenlty i can only include one link)

I've tried hosting the buttons in a FlowLayoutPanel but they do not increase as the dialog stretches, I only get whitespace at the bottom after I run out of buttons. I also tried a TableLayoutPanel and had the same result but I may have misused it. Does anyone have any ideas how I could accomplish this?

Thanks in advance, Jeremy

+1  A: 

To get you started. Use the TableLayoutPanel, set its Anchor property to top, bottom, left, and right. Set the rows and columns to percentages as needed. I suggest each control have it own cell. Note that each control in a "cell" can have its Dock and Anchor property set as needed.

AMissico
Thanks for the info, it worked perfectly. One gotcha, however,...i couldn't get the TableLayoutPanel to simultaneously set the Anchor property to all four points and the Dock style to Fill. Setting one always reset the other, but this may have been a side effect of the third party control toolkit that was hosting the TableLayoutPanel. Regardless, when I set the Dock style of the TableLayoutPanel as well as it's child controls to Fill the controls stretched perfectly across the form.Thanks again!
Jeremy Jarrell
Yes, Anchor and Dock are exclusive. You can only set one or the other. If you want both, the use a Panel to "anchor" then "dock" your control in the Panel.
AMissico
A: 

You can do this with a TableLayoutPanel. Create a column for the buttons, with each button having it's own row / cell in the column. Set each row to be an even percentage for height (if there are 10 buttons, each row would be 10%), and dock the TableLayoutPanel to the right side of the screen. Then, put the buttons into their rows and set them to full docking. Then, when the dialog expands, the TableLayoutPanel will expand to fill the entire right side of the screen, each row will adjust proportionally, and each button would expand to fit the new row size.

You may have to adjust this a bit to fit your needs, especially in how it relates to the other content in the window.

NYSystemsAnalyst