See Also Example
Form, picture box
Occurs when part or all of a form or picturebox is exposed after it has been moved or enlarged, or after a window that was covering the object has been moved.
Sub Form_Paint ( )
Sub ctlname_Paint ([Index As Integer])
The argument Index uniquely identifies a control if it is in a control array
A Paint procedure is useful if you have output from graphics methods With a Paint procedure, you can ensure that such output is repainted when necessary.
If the AutoRedraw The Paint event is also invoked when the Refresh method is used.
Using a Refresh method in a Resize
Note Using a Paint event procedure for certain tasks can cause a cascading event . In general, avoid using a Paint procedure for the following:
Moving or sizing a form or control.
Changing any variables that affect size or visual appearance such as setting an object's BackColor property.
Invoking a Refresh method.
A Resize event procedure may be more appropriate for some of these tasks.
Chapter 15, "Creating Graphics for Applications"
Paint Event Example
The example draws a diamond that intersects the center point of each side of a form and adjusts automatically as the form is resized. To try this example, paste the code into the Declarations section of a form. Then press F5 and resize the form.
Sub Form_Paint ()
Dim HalfX, HalfY ' Declare variables.
HalfX = ScaleLeft + ScaleWidth / 2 ' Set to half of width.
HalfY = ScaleTop + ScaleHeight / 2 ' Set to half of height.
' Draw a diamond.
Line (ScaleLeft, HalfY) - (HalfX, ScaleTop)
Line -(ScaleWidth + ScaleLeft, HalfY)
Line -(HalfX, ScaleHeight + ScaleTop)
Line -(ScaleLeft, HalfY)