First off we must subclass the good old textbox, but hopefully you aer doing this already in your component lib. Next it's a matter of hooking up to the windows message and drawing accordingly.
You should end up with this ...
Public Class Component1
Inherits TextBox
Private Const WM_PAINT As Integer = &HF
Private bMandatory
Public Property Mandatory() As Boolean
Get
Return bMandatory
End Get
Set(ByVal value As Boolean)
bMandatory = value
Me.Invalidate()
End Set
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
Try
MyBase.WndProc(m)
If m.Msg = WM_PAINT And bMandatory Then
Dim g As Graphics = Me.CreateGraphics
Dim pts As PointF() = {New PointF(0, 0), New PointF(5, 0), _
New PointF(0, 5)}
g.FillPolygon(Brushes.Red, pts)
End If
Catch ex As Exception
' Call error handler
End Try
End Sub
End Class
No comments:
Post a Comment