Although the textbox doesn't have a paint event i'd found a solution.
All you paint code must be done inside the Draw Sub.
The code inside the Draw sub is just a example.
Code:
DebuggerDisplay("Name = {Name} Text = {Text}")> _
Public Class TextBoxEnabledColor
Inherits TextBox
Const WM_PAINT = &HF
<System.Diagnostics.DebuggerStepThrough()> _
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
If m.Msg = WM_PAINT Then
Draw()
End If
End If
End Sub
Private Sub Draw()
Dim RctControl As Rectangle
Dim StfControl As StringFormat = New StringFormat
Dim GrpControl As Graphics
GrpControl = Graphics.FromHwnd(Me.Handle)
GrpControl.FillRectangle(Brushes.White, Me.DisplayRectangle)
If Me.TextAlign = HorizontalAlignment.Right Then
StfControl.Alignment = StringAlignment.Far
GrpControl.DrawString(Me.Text, Me.Font, Brushes.Black, Me.DisplayRectangle.Right, 1, StfControl)
Else
StfControl.Alignment = StringAlignment.Near
GrpControl.DrawString(Me.Text, Me.Font, Brushes.Black, Me.DisplayRectangle.Left, 1, StfControl)
End If
End Sub
End Class