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?
 
É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
 
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
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
 
É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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.