AutoRedraw Property

       

Returns or sets the output from a graphics method to a persistent graphic.

Syntax

object.AutoRedraw [= boolean]

The AutoRedraw property syntax has these parts:

Part Description
Object An object expression that evaluates to an object in the Applies To list.
Boolean A Boolean expression that specifies how the object is repainted, as described in Settings.

Settings

The settings for boolean are:

Setting Description
True Enables automatic repainting of a Form object or PictureBox control. Graphics and text are written to the screen and to an image stored in memory. The object doesn't receive Paint events; it's repainted when necessary, using the image stored in memory.
False (Default) Disables automatic repainting of an object and writes graphics or text only to the screen. Visual Basic invokes the object's Paint event when necessary to repaint the object.

Remarks

This property is central to working with the following graphics methods: Circle, Cls, Line, Point, Print, and PSet. Setting AutoRedraw to True automatically redraws the output from these methods in a Form object or PictureBox control when, for example, the object is resized or redisplayed after being hidden by another object.

You can set AutoRedraw in code at run time to alternate between drawing persistent graphics (such as a background or grid) and temporary graphics. If you set AutoRedraw to False, previous output becomes part of the background screen. When AutoRedraw is set to False, background graphics aren't deleted if you clear the drawing area with the Cls method. Setting AutoRedraw back to True and then using Cls clears the background graphics.

Note   If you set the BackColor property, all graphics and text, including the persistent graphic, are erased. In general, all graphics should be displayed using the Paint event unless AutoRedraw is set to True.

To retrieve the persistent graphic created when AutoRedraw is set to True, use the Image property. To pass the persistent graphic to a Windows API when AutoRedraw is set to True, use the object's hDC property.

If you set a form's AutoRedraw property to False and then minimize the form, the ScaleHeight and ScaleWidth properties are set to icon size. When AutoRedraw is set to True, ScaleHeight and ScaleWidth remain the size of the restored window.

If AutoRedraw is set to False, the Print method will print on top of graphical controls such as the Image and Shape controls.