Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fit controls on resized form

Tags:

c#

forms

controls

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.

like image 386
NeverJr Avatar asked Mar 08 '13 21:03

NeverJr


1 Answers

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.
like image 137
Paul Sasik Avatar answered Nov 01 '22 16:11

Paul Sasik