Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Disable colors
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00667848
Message ID:
00668012
Vues:
27
In VB .NET you need to override the OnPaint event of the TextBox to render the colors you want. When the textbox is disabled (Enabled=False), the OnPaint event is called and will display the colors you define. Here is sample code for a sub-class of the base TextBox:

Public Class MyTextBox
Inherits TextBox

Public Sub New()
' This call is required by the Windows.Forms Form Designer.
MyBase.New()
Me.SetStyle(ControlStyles.UserPaint, True)
End Sub 'New '

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim drawBrush As SolidBrush
If Enabled Then
'Use the ForeColor specified in the properties dialog.
drawBrush = New SolidBrush(ForeColor)
'Set the BackColor to the Windows default
BackColor = Color.FromName("Window")
Else
'What color you want to use for your disabled ForeColor
drawBrush = New SolidBrush(Color.Red)
'Set the BackColor to the color you want
BackColor = Color.Aqua
End If
' Draw string to screen.
e.Graphics.DrawString(Text, Font, drawBrush, 0.0F, 0.0F)
End Sub 'OnPaint
End Class


>I'm just getting into VB.Net after years of experience with VFP.
>
>VFP textboxes (and other controls) allow setting colors for both the enabled and disabled state of the control. I can't seem to find the same functionality in VB.Net. Is this functionality available in VB.Net?
>
>Thanks
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform