Search code examples
c#winformsscreen-resolution

Why can not I adjust the form to the size of the monitor? (Windows Forms)


I have made an application in visual C # (Windows Forms), and the monitor of my PC is 1280 x 1024.

The appearance of the form is as indicated in the following figure:

enter image description here

There are several users who have PCs with other resolutions, for example 1024 x 768 and the form looks like this:

enter image description here

I have made all the suggestions I have found in several forums and what I have noticed is that the controls contained in the form are those that must also be resized.

Any suggestions to solve my problem is welcome.


Solution

  • You should set the Anchor and Dock properties on the controls in the forms.

    The Anchor property controls which edges of control are "bound" or "tied" to the corresponding edges of its form. For example, if you set Anchor to Bottom, the distance between the control's bottom edge and the bottom of its parent will not change, so the control will move down as you resize the form. If you set Anchor to Top | Bottom, the control will resize vertically as you resize the form.

    To make a control resize with the form, set the Anchor to all four sides, or set Dock to Fill.