2012-10-22 32 views
0

有沒有人在這裏看到我的錯誤?VB.NET VisualStyleRenderer不工作

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 

回答

1

你不應該畫CreateGraphics();它在下次控制着色時將被擦除。

取而代之,您需要處理Paint事件並利用e.Graphics

+0

謝謝!我將如何繪製到PictureBox的持久DC?或者是一個持久的DC只是VB6給我的錯覺? – tmighty