How to make controls expand to fill screen in fullscreen mode

M

MJ

I design my forms in Visual Studio, which has limited screen space for the
form. After compilation, I run the project and expand the form to
fullscreen mode, but the controls and other elements on the form remain
fixed -- they don't expand to fill the entire screen.

How can make the controls and other elements on the form expand to
fullscreen mode?

Thanks for any help.
 
S

Stoitcho Goutsev \(100\) [C# MVP]

MJ,

There is two ways to make the control follows the size of the form - using
the Dock property and using the Anchor property.

I'd suggest using control's Dock property. besically you add controls and
arange them left, top, bottom. The last control you add you set dock to Fill
and will fill the empty space.

Anchoring on the other hand is fixing the sides of the control to stay in
the same distance according to the edges of the container. For example if
you place a button at position 100,100 the anchoring by default is Left-Top
and that means the upper edge of the control will be 100 pixels down of the
upper edge of the container and the left edge of the control is 100 pixels
right of the left edge of the container. If the container is the form and
you resize the form the control will stay on the same place relative to the
upper and the left side of the form. If you change the anchoring to
Top-Right for example the control will stick in the same position relative
to the upper and right edges of the form thus when you resize horizontally
the control will appear moving.
Apparently if you anchor the control to the all four sides it will resize
along with the form.
 
M

MJ

Stoitcho,

Thanks very much for your reply. The Dock properties of the controls did
the trick.

Many thanks !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top