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:
00673127
Vues:
19
Cathi -

Thanks for replying to my question.

I tried the class sample code you provided, and the textbox disabled colors did change. However, as soon as an enabled instance of the control receives focus, the font of the control changes from the defined font. I'm pretty sure the drawstring call is being passed the correct font (I displayed it in a msgbox before the call).

I was wondering if you had any additional information that would pertain to this screen glitch. I would actually like to develop a UserControl based on the textbox which would not only provide color settings, but also include a masking feature for phone numbers, etc...

Thanks in advance for any information you may pass along.

Rick Napolitan




>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform