Hello,
I have made the following class to make a textbox that has a different background / foreground color when disabled :
Now I have the following problem :
When the form starts with the textbox enabled, everything looks fine (normal black text). Then I try to disable the textbox. This also gives the expected result. But when I enable the textbox again, the text in the textbox is now bold.
How can I obtain that the text doesn't turn to bold after disabling / enabling the textbox ?
Grtz,
I have made the following class to make a textbox that has a different background / foreground color when disabled :
VB.NET:
[COLOR="DarkSlateBlue"]Public Class vaTextBox
Inherits Textbox
Public Sub New()
MyBase.New()
End Sub
Public Shadows Property Enabled() As Boolean
Get
Return MyBase.Enabled
End Get
Set(ByVal Value As Boolean)
If Value = True Then
Me.SetStyle(ControlStyles.UserPaint, False)
Else
Me.SetStyle(ControlStyles.UserPaint, True)
End If
MyBase.Enabled = Value
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Using oBrush As New SolidBrush(Color.WhiteSmoke)
e.Graphics.FillRectangle(oBrush, Me.ClientRectangle)
End Using
Using oBrush As New SolidBrush(Me.ForeColor)
e.Graphics.DrawString(Me.Text, Me.Font, oBrush, -1, 1)
End Using
End Sub
End Class[/COLOR]
Now I have the following problem :
When the form starts with the textbox enabled, everything looks fine (normal black text). Then I try to disable the textbox. This also gives the expected result. But when I enable the textbox again, the text in the textbox is now bold.
How can I obtain that the text doesn't turn to bold after disabling / enabling the textbox ?
Grtz,