How does .NET repaint controls?
- by serhio
Say I have a custom Label that I paint in my way.
As lite example we have the code:
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
' MyBase.OnPaint(e) DO NOT USE '
Dim f As Font = Me.Font
Dim g As Graphics = e.Graphics
Dim textRect As Rectangle = New Rectangle(Me.Location, Me.Size)
Using br As New SolidBrush(Me._TextColor)
g.DrawString(_Text, f, br, textRect)
End Using
End Sub
maybe this example is useless, because does not bring different behavior that a simple label, but it just for example.
Now, the problem is that if this label moves the ancient label area will not be updated, and the old text will remain until the parent will be invalidated.
So the question is:
How to invalidate the former control region?