Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing Controls when Form Resizes

Status
Not open for further replies.

UncleCake

Technical User
Feb 4, 2002
355
US
Hi,

I need to resize controls in a form when it is resized, which I have never done. I have searched for other help and tutorials, but I haven't found much.

My over all goals are to have the form size proportionally only and have the controls fit within the form. My biggest culprit is a large spread sheet control displaying lots of data.

Is this possible?

-Uncle Cake
 
You need to place some code in the Form_Resize event
e.g.
Code:
Private Sub Form_Resize()

   'This keeps the command button in the horizontal centre of the form
   'and 1100 from the bottom
   cmdOK.Left = (me.Width - cmdOK.Width) / 2
   cmdOK.Top = Me.Height - 1100

End Sub
Trevor
 
You could also use the move method which, depending on what is being resized may keep things smoother on the eye. The code is myControl.Move sngLeft, sngTop, sngWidth, sngHeight. You don't have to enter all the arguments since they are all optional.
-Max
 
<depending on what is being resized may keep things smoother on the eye.

Interesting tip, Max. I've never really used the Move method, just resetting properties instead. I'll have to try it.

Also, I generally use ScaleWidth and ScaleHeight, which are the usable height and width of the form.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top