Link to home
Start Free TrialLog in
Avatar of cmdolcet
cmdolcetFlag for United States of America

asked on

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 ?
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

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.
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.
Avatar of cmdolcet

ASKER

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?
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?
Give me until next week to get something together as a true example.

Thanks,
SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is there any way you could provide an example using a panel and a couple of controls inside that panel.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.