Automatically resize forms depending on the resolution of the screen

Asked By 10 points N/A Posted on -
qa-featured

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.

SHARE
Best Answer by zislam007
Answered By 0 points N/A #114259

Automatically resize forms depending on the resolution of the screen

qa-featured
  • When you resize your screen resolution, everything inside that screen is automatically formatted to fit the screen.
  • If you were referring to documents in programs such as in MS Word, Photoshop and other similar applications, then the documents will be sized as you had them originally.
  • But as in MS Word; you can go to documents, zoom, fit to screen or select whichever zoom you prefer.
  • The same process applies to other programs i.e. the option to Resize your document should be under zoom; although when you resize the screen resolution everything else will be resized accordingly.
Best Answer
Best Answer
Answered By 0 points N/A #114260

Automatically resize forms depending on the resolution of the screen

qa-featured

I am proposing two solutions.

Solution 1:

The Anchor property interacts with the Autosize property.

To anchor a control on a form

  1. Select the control you want to anchor.
  2. In the Properties window, click the arrow to the right of the Anchor property
  3. An editor is displayed that shows a cross.
  4. To set an anchor, click the top, left, right, or bottom section of the cross.
  5. Controls are anchored to the top and left by default.
  6. To clear a side of the control that has been anchored, click that arm of the cross.
  7. 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.

Login/Register to Answer

Related Questions