Tuesday, August 3, 2010

Resize WinForm Controls Automatically

Let' say you have a form with a ListBox and OK and Cancel buttons.
 




You want controls to be resized automatically when a form is resized. This is how you can achieve this by using the Anchor property:

Place all controls inside a GroupBox. Set the Anchor and Dock properties

GroupBox properties:
Anchor : Top, Bottom, Left, Right
Dock : None

Buttons properties:
Anchor : Bottom, Right
Dock : None

ListBox properties:
Anchor : Top, Bottom, Left, Right
Dock : None

No comments:

Post a Comment