Resize Event

See Also1K8UD5O                 ExampleJQ87PM>Low

Applies To

Form14TJ2LN, MDI form1ILMZQ7, OLE control2HQDVVU, picture box31MYIWX.

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 ScaleHeight3J8U7ZN and ScaleWidth3J8U7ZN) that may depend on the size of the form.  To invoke the Paint25UTDKO event every time a form is resized, use the Refresh3SMNZGP method in a Resize procedure if you want graphics to maintain sizes proportional to the form when the form is resized.

Whenever the AutoRedraw1UY7ZM3 property is set to False and the form is resized, Visual Basic also calls the related events in the order Resize, Paint.  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.


See Also

Help:

AutoRedraw Property1UY7ZM3

Load StatementGU0759

Paint Event25UTDKO

Refresh Method3SMNZGP

Show Method2IF9Z3Q

 

Programmer's Guide:

Chapter 15, "Creating Graphics for Applications"


Resize Event Example

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