Visual Basic Reference

Resize Event

See Also    Example    Applies To

Occurs when an object is first displayed or when the window state of an object changes. (For example, a form is maximized, minimized, or restored.)

Syntax

Private Sub Form_Resize( )

Private Subobject_Resize(height As Single,widthAs Single)

The Resize event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
height Number specifying the new height of the control.
width Number specifying the new width of the control.

Remarks

Use a Resize event procedure to move or resize controls when the parent form is resized. You can also use this event procedure to recalculate variables or properties, such as ScaleHeight and ScaleWidth, that may depend on the size of the form. If you want graphics to maintain sizes proportional to the form when it's resized, invoke the Paint event by using the Refresh method in a Resize event procedure.

Whenever the AutoRedraw property is set to False and the form is resized, Visual Basic also calls the related events, Resize and Paint, in that order. When you attach procedures for these related events, be sure their actions don't conflict.

When an OLE container control's SizeMode property is set to 2 (Autosize), the control is automatically sized according to the display size of the object contained 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 for the object before the OLE container control is resized. The height and width 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 height and width parts in the Resize event.