29 Ocak 2010 Cuma

disable textbox renk değiştirme

 enable =false (disable olmuş) olan bir textbox kontrolünün rengini nasıl değiştiririz ?

Public Class VisualTextbox
Inherits TextBox

Public Sub New()
' Initialise the class
MyBase.New()
End Sub

Public Shadows Property Enabled() As Boolean
Get
Return MyBase.Enabled
End Get
Set(ByVal Value As Boolean)
' Switch draw styles if disabled
Me.SetStyle(ControlStyles.UserPaint, Not Value)
' Set the underlying value
MyBase.Enabled = Value
End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)

' Draw the bg in
e.Graphics.FillRectangle(New SolidBrush(Color.LightGray), Me.ClientRectangle)

' Draw the appropriate text in using the fore color
e.Graphics.DrawString(Me.Text, Me.Font, New SolidBrush(Me.ForeColor), -1, 1)
End Sub

End Class