tmighty
tmighty

Reputation: 11409

VB.NET VisualStyleRenderer not working at all

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

Upvotes: 0

Views: 200

Answers (1)

SLaks
SLaks

Reputation: 888117

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.

Upvotes: 1

Related Questions