How to resize a form and its different controls.

I have a form that has a multitude of controls on it ( Labels,TExtbox,combo box, grids radio button and group boxes). I would like a streamline way on how to easily resize a form based on the users screen size.

I have the following code:

Dim X as Integer= my.computer.Screen.Bounds.Height
Dim Y as Integer = my.computer.screen.bounds.width

Sub FrmLoad ()
me.size = new size(X,Y)

Open in new window


I also changed the following properties on the form itself.
AutoSize = True
AutoSizeMode = GrowAndShrink


Do I need to to anything with the labels and textboxes and combobox ?
cmdolcetAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun KlineLead Software EngineerCommented:
Forms have a property called WindowState that you can set to Normal, Maximized, or Minimized. This property will handle making your form fill the entire screen (Maximized).

From there, you can use the Anchor property on controls to determine how a control resized / moves when a form size changes.
0
Éric MoreauSenior .Net ConsultantCommented:
what do you want to happen on labels and textboxes? Often, we set the Anchor property to extend to the right to the textboxes so they extend to resize to the form accordingly.
0
cmdolcetAuthor Commented:
Yes I should of mentioned that in the first place. I would like each control to resize the position on the form so things dont get cut off.

For example.

I have a status bar and a progress bar both are set to dock to the bottom and anchored  (Top Left) when I add this code:

Dim X as Integer= my.computer.Screen.Bounds.Height
Dim Y as Integer = my.computer.screen.bounds.width
Sub FrmLoad ()
me.size = new size(X,Y)

Open in new window


With the form properties set to:

AutoSize = True
AutoSizeMode = GrowAndShrink

It seems to cut off my status bar and progress bar?
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Éric MoreauSenior .Net ConsultantCommented:
Anchoring is useless when docking.

I am not sure to understand what you mean. Do you have test code you can share? or an image?
0
cmdolcetAuthor Commented:
Give me until next week to get something together as a true example.

Thanks,
0
Éric MoreauSenior .Net ConsultantCommented:
OK. Usually when a control is dock, it gets automatically resized when the form is resized.
0
cmdolcetAuthor Commented:
So If I dock a control say a panel tat is docked to the form and inside that panel I have other controls (labels, radio button) those will get resized with the panel.
0
Éric MoreauSenior .Net ConsultantCommented:
Docking a panel is not enough to have every contained controls to be resized automatically. Each control has to be set to answer to resize. You need to set the Anchor property for example.
0
cmdolcetAuthor Commented:
Is there any way you could provide an example using a panel and a couple of controls inside that panel.
0
Éric MoreauSenior .Net ConsultantCommented:
It greatly varies according to the controls YOU are using. For example, a grid won't be set the same way as a textbox. Have a look at https://www.techrepublic.com/article/manage-winform-controls-using-the-anchor-and-dock-properties/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob ValentineCPA / Owner - Cellutionware SoftwareCommented:
I use a dll called Softgroup .Net Forms Resize to resize the controls on my forms. It does a great job. They have a free trial version.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.