Solved

Controls resize depending on the monitor size

Posted on 2016-10-05
7
26 Views
Last Modified: 2016-10-11
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
0
Comment
Question by:RIAS
  • 3
  • 3
7 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41830315
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.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41830400
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
0
 

Author Comment

by:RIAS
ID: 41831874
Thanks,
But the controls in tabpage are not resizing.
Any suggestions are appreciated.

Cheers
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41831885
>>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?
0
 

Author Comment

by:RIAS
ID: 41831892
Yes,
Tried Anchor but they resize and they stick to each other.May be I am doing something terrible wrong
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 41831912
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.
1
 

Author Comment

by:RIAS
ID: 41834048
Will try Eric!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question