0

Does anybody see my mistake here?

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
    Dim renderer As VisualStyleRenderer
    renderer = New VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)

    Dim nRect As New Rectangle
    nRect = Rectangle.FromLTRB(0, 0, 100, 100)

    renderer.DrawBackground(Me.PictureBox1.CreateGraphics, nRect)
    Me.PictureBox1.Invalidate(True)
End Sub
Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
tmighty
  • 10,734
  • 21
  • 104
  • 218

1 Answers1

1

You should never draw on CreateGraphics(); it will be erased next time the control paints itself.

Instead, you need to handle the Paint event and draw on e.Graphics.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Thank you! And how would I draw into the PictureBox's persistent DC? Or is a persistent DC only an illusion that VB6 gave me? – tmighty Oct 22 '12 at 18:18