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

AutoRedraw Property Example

This example alternately displays two graphics on a PictureBox control: a persistent filled circle and temporary vertical lines. Click the PictureBox to draw or redraw the lines. Resizing the form requires the temporary graphic to be redrawn. To try this example, paste the code into the Declarations section of a form that has a PictureBox control named Picture1. Press F5 to run the program, and click the graphic each time you resize the form.

Private Sub Form_Load ()
   Picture1.ScaleHeight = 100   ' Set scale to 100.
   Picture1.ScaleWidth = 100
   Picture1.AutoRedraw = True   ' Turn on AutoRedraw.
   Picture1.ForeColor = 0   ' Set ForeColor.
   Picture1.FillColor = QBColor(9)   ' Set FillColor.
   Picture1.FillStyle = 0   ' Set FillStyle.
   Picture1.Circle (50, 50), 30   ' Draw a circle.
   Picture1.AutoRedraw = False   ' Turn off AutoRedraw.
End Sub

Private Sub Picture1_Click ()
   Dim I   ' Declare variable.
   Picture1.ForeColor = Rgb(Rnd * 255, 0, 0)   ' Select random color.
   For I = 5 To 95 Step 10   ' Draw lines.
      Picture1.Line (I, 0)-(I, 100)
End Sub
© 2015 Microsoft