See Also Example
Applies To
Form, MDI form
Description
Occurs when a form first appears or the size of an object changes.
Syntax
Sub { Form|MDIForm|picturebox}_Resize ( )
Sub OLEControl_Resize (heightnew As Single, widthnew As Single)
Remarks
Use a Resize procedure to move or resize controls when the parent form is resized. You can also use a Resize procedure to recalculate variables or properties (such as ScaleHeight and ScaleWidth ) that may depend on the size of the form. To invoke the Paint event every time a form is resized, use the Refresh method in a Resize procedure if you want graphics to maintain sizes proportional to the form when the form is resized.
Whenever the AutoRedraw When you attach procedures for these related events, be sure their actions don't conflict.
When an OLE control's SizeMode property is set to 2 (autosize), the control is automatically sized according to the display size of the object in the control. If the display size of the object changes, the control is automatically resized to fit the object. When this occurs, the Resize event is invoked before the OLE control is resized. The heightnew and widthnew parts indicate the optimal size for displaying the object (this size is determined by the application that created the object). You can size the control differently by changing the values of the heightnew and widthnew parts in the Resize event.
Help:
AutoRedraw Property
Load Statement
Paint Event
Refresh Method
Show Method
Programmer's Guide:
Chapter 15, "Creating Graphics for Applications"
The example automatically resizes a text box to fill the form whenever the form is resized. To try this example, paste the code into the Declarations section of a form that contains a text box. Set the text box MultiLine property to True, the ScrollBars property to 3, and the BorderStyle to 0. Then press F5 and resize the form.
Sub Form_Load ()
Text1.Text = "" ' Clear text.
End Sub
Sub Form_Resize ()
Text1.Move 0,0, ScaleWidth, ScaleHeight
End Sub