How does .NET repaint controls?
Posted
by serhio
on Stack Overflow
See other posts from Stack Overflow
or by serhio
Published on 2010-05-02T22:41:09Z
Indexed on
2010/05/02
22:48 UTC
Read the original article
Hit count: 237
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?
© Stack Overflow or respective owner