Controls resize depending on the monitor size

RIAS
RIAS used Ask the Experts™
on
Hello,

Iam using vb.net 2015.  Is there any way that I can resize the controls on the form and the resize the  form  depending on the monitor size.

Cheers
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kyle AbrahamsSenior .Net Developer

Commented:
I normally set an anchor to the controls so they'll grow automatically.

You can use the screen class to determine the resolution of the screen:
https://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx
 Dim screenWidth as Integer = Screen.PrimaryScreen.Bounds.Width
 Dim screenHeight as Integer = Screen.PrimaryScreen.Bounds.Height

Open in new window


You can then set the form's height and width to whatever you like.
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
I also use the Anchor property which I sometimes combine with Layout containers: http://emoreau.com/Entries/Articles/2010/01/The-Table-and-Flow-Layout-container-controls.aspx

Author

Commented:
Thanks,
But the controls in tabpage are not resizing.
Any suggestions are appreciated.

Cheers
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
>>But the controls in tabpage are not resizing.

I have forms with tab pages and they are resizing so the problem is definitely not there. But since we don't wee how you set your stuff, we can't fully help you.

One blind guess: have you set the Anchor property for your controls inside the tabpages?

Author

Commented:
Yes,
Tried Anchor but they resize and they stick to each other.May be I am doing something terrible wrong
Senior .Net Consultant
Top Expert 2016
Commented:
how do you anchor them?

in a traditional application, you often have textboxes at the top and a grid at the bottom. the top controls are usually anchor to left, top  and right (so they stay at the same position but enlarge the width if possible) while the grid at the bottom could be anchor on all 4 sides to use the remaining space.

maybe you would be better with a table flow layout as shown in my article.

Author

Commented:
Will try Eric!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial