6

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.

NeverJr
  • 307
  • 2
  • 11
  • Possible duplicate of [How to auto resize and adjust Form controls with change in resolution](http://stackoverflow.com/questions/4248637/how-to-auto-resize-and-adjust-form-controls-with-change-in-resolution) – Jim Fell May 17 '16 at 17:06

4 Answers4

3

There are several ways:

  1. 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.
  2. 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.
  3. 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
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
-1

You have to scale them manually, ther is no automatic way to do that.

If it's only one control you are trying to fit to the window size, setting Dock property to Fill will get the job done.

virious
  • 571
  • 1
  • 8
  • 27