Link to home
Start Free TrialLog in
Avatar of kvnsdr
kvnsdr

asked on

C#: Resizing Window Applications at runtime?

I like the way other windows programs allow the end user to click-n-drag the bottom-right corner and customize its size. This much I can do, however I would like any controls to resize accordingly to the window, for example, if there is a listview. Currently when I resize the window, the controls stay exactly in place.

Q. How do I setup my app to resize-all when an end user resizes the main window?
Avatar of smegghead
smegghead
Flag of United Kingdom of Great Britain and Northern Ireland image

You can achieve this using the 'Anchor' property, in conjunction with splitter bars, and the 'Dock' property.

When you set the anchor property, it says that you are anchoring a side of the control to it's container.

So, if you have one listbox on your form anchored to each side, when you re-size your form, it will leave the same gaps between the control and it's container.

It gets quite complicated when you've got lots of controls on your form, but you can get around this by putting your controls in a group box, to keep them together, then docking or anchoring that group box.
ASKER CERTIFIED SOLUTION
Avatar of smegghead
smegghead
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial