Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Visual Basic Reference

Visual Studio 6.0

Paint Event

See Also    Example    Applies To

Occurs when part or all of an object is exposed after being moved or enlarged, or after a window that was covering the object has been moved.

Syntax

Private Sub Form_Paint( )

Private Sub object_Paint([index As Integer])

The Paint event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
index An integer that uniquely identifies a control if it's in a control array.

Remarks

A Paint event procedure is useful if you have output from graphics methods in your code. With a Paint procedure, you can ensure that such output is repainted when necessary.

The Paint event is invoked when the Refresh method is used. If the AutoRedraw property is set to True, repainting or redrawing is automatic, so no Paint events are necessary.

If the ClipControls property is set to False, graphics methods in the Paint event procedure affect only newly exposed areas of the form; otherwise, the graphics methods repaint all areas of the form not covered by controls (except Image, Label, Line, and Shape controls).

Using a Refresh method in a Resize event procedure forces repainting of the entire object every time a user resizes the form.

Note   Using a Paint event procedure for certain tasks can cause a cascading event. In general, avoid using a Paint event procedure to do the following:

  • Move or size a form or control.

  • Change any variables that affect size or appearance, such as setting an object's BackColor property.

  • Invoke a Refresh method.

A Resize event procedure may be more appropriate for some of these tasks.

Show:
© 2015 Microsoft