Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting forecolor in disabled textbox
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00892517
Message ID:
00892551
Vues:
21
Todd,

Try using ReadOnly instead of Disabled, the ReadOnly field will still recieve the Focus, allow Copy operations but you will be able to update the ForeColor.

If you really want to control the ForeColor on a Disabled control then you will have to ownerdraw it. This can be achieved by subclassing the TextBox control and:-

1] Setting the UserPaint style bit to true in the constructor.
2] Override the WndProc event processing method and respond to messages.
public myTextBox
{
   this.SetStyle(ControlStyles.UserPaint, true);
   this.UpdateStyles();
}

protected override void WndProc(ref Message m)
{
   //
   // Do lots of crazy things in here including handling
   // the following Windows messages:-
   //
   // WM_PAINT
   // WM_HSCROLL
   // WM_VSCROLL
   // WM_LBUTTONDOWN
   // WM_RBUTTONDOWN
   // WM_LBUTTONDBLCLK
   // WM_MOUSELEAVE
   // WM_MOUSEMOVE
   //

}
The downside to ownerdrawing is that you will not get any help in rendering your control ie. you will have to draw *all* the states that you need to cater for, caret positioning etc.

HTH
Neil
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform