Asked By
james596
10 points
N/A
Posted on - 08/13/2011
Hello!
I am working on a project and I realized that it contains a set of forms on a screen resolution of 1920 * 1080, but I would want to move to a screen resolution of 1280 * 820.
Please, suggest a solution on how I can code or do some programming to automatically resize the forms according to the resolution of the screen.
Thank you in advance.
Automatically resize forms depending on the resolution of the screen
I am proposing two solutions.
Solution 1:
The Anchor property interacts with the Autosize property.
To anchor a control on a form
-
Select the control you want to anchor.
-
In the Properties window, click the arrow to the right of the Anchor property
-
An editor is displayed that shows a cross.
-
To set an anchor, click the top, left, right, or bottom section of the cross.
-
Controls are anchored to the top and left by default.
-
To clear a side of the control that has been anchored, click that arm of the cross.
-
To close the Anchor property editor, click the Anchor property name again.
-
When your form is displayed at run time, the control resizes to remain positioned at the same distance from the edge of the form.
-
The distance from the anchored edge always remains the same as the distance defined when the control is positioned in the Windows Forms Designer.
Solution 2:
-
Basically anchor and dock properties are used to resize a control according to the screen resolution. But in cases where you have lots of controls in your form, then you should consider this option.
-
The best way to go about it is to use table-layout and flow-layout panel because both of these panel controls provide intuitive ways of arranging controls on your form.
-
The table-Layout Panel control provides a proportional resizing capability at run time, so your layout can change smoothly as your form is resized as well as all the controls are anchored to all the sides of the cell in which you keep them.
-
In fact, I want to suggest that when you need a dynamic layout and you do not want to handle layout events explicitly in your code, then you should consider using a layout panel.