views:

1359

answers:

4

If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls.

How can I achieve this?

+1  A: 

Play around with the Dock and Anchor properties of your panels.

MusiGenesis
+3  A: 

You can use the TableLayoutPanel and set column width at x% each this way you will have the screen split in 2. The TableLayoutPanel must be Dock to fill all the form or Anchor.

The TableLayoutPanel can contain other panel. OR you can use simply your panel and use Anchor (click the panel and go in the Properties panel of VS).

Daok
+7  A: 

If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls.

You're the ideal use case for TableLayoutPanel (MSDN). If you were only scaling the panels, Dock and Anchor would be appropriate. But since you want your controls to scale well, you're pretty much in an AutoLayout world, and likely the TableLayoutPanel. (I'm a huge fan of this, by the way, although overuse can have a negative performance impact on laying out your controls.)

Some helpful links on using it to configure your layout to scale:

John Rudy
Argh. I write software for Windows Mobile devices, and once again I just had the experience of learning about a cool .NET feature that isn't in the Compact Framework.
MusiGenesis
For future visitors of this answer: I just noticed a link to my blog in this answer, and have now removed it, as I shut the blog down many months ago. I apologize for the inconvenience.
John Rudy