Can controls grow with form?

S

Simon Shaw

Can controls be made to grow with a form as it is resized, like they can in
Outlook forms?
Sorry - can't find this in any FAQ but sure it's a simple one.
TIA
Simon
 
R

Rick Brandt

Simon said:
Can controls be made to grow with a form as it is resized, like they
can in Outlook forms?
Sorry - can't find this in any FAQ but sure it's a simple one.
TIA
Simon

Sure, but you have to write the code that does the resizing and place it in the
OnResize event of the form.
 
D

Douglas J Steele

You can put code into the form's Resize event to change the Height and Width
properties of the various controls on the form.

To loop through all of the controls on a form, you can use code like:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls

Next ctlCurr

You'll probably want to include logic to do different adjustments based on
the type of control. To do that, you'd use the TypeOf operator:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If TypeOf ctlCurr Is CommandButton Then
' You probably don't want to resize the Command Buttons
' (or at least not at the same rate as, say, text boxes)

ElseIf TypeOf ctlCurr Is CheckBox Then
' There's no point resizing a check box!

ElseIf TypeOf ctlCurr Is TextBox Then
' Set the control's Width and Height as a percentage
' of the form's Width and Height

End If
Next ctlCurr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top