I would like to fit the control on the form, when I change the resolution. Because now when I set for example an 1280x1024 resolution the controls stay at the top left corner and the original size. I mean I would like to change their positions and sizes too with the form.
Asked
Active
Viewed 2,122 times
4 Answers
3
There are several ways:
- Set the Dock property of the control to Fill - This is the simplest but depends on whether the control is alone in the parent and if not, how other controls need to resize with it.
- Set the Anchor property of the control to Top, Bottom, Left, Right - This causes your control "to stick" to anchored points and either move and/or resize depending on the anchors selected.
- You can react to the Resize event of the parent control and resize the control manually but this should only be necessary in very special circumstances such as when you need to fit several different controls next to each other with, for example, percentage sizing logic.

Paul Sasik
- 79,492
- 20
- 149
- 189
1
Get familiar with Anchor
property of controls.
It's designed to do things you need.

Kamil
- 13,363
- 24
- 88
- 183
-
2It will only help with positions of the controls, not with their size. – virious Mar 08 '13 at 21:46
-
1@virious: Anchoring can resize the control. You just need to anchor two opposite sides. – Paul Sasik Mar 08 '13 at 21:48
0
Proper use of Anchors allows controls to move, or stretch, depending on your desires. If two opposite sides of a control are Anchored, it will stretch on that axis (top_bottom/left_right). Otherwise, it will remain locked to its Anchored side. Docking is like anchoring, but with per-defined settings.

Nevyn
- 2,623
- 4
- 18
- 32