Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Disabled forecolor
Message
De
01/03/2009 16:46:17
John Thomason
King Richard Veterinary Centre
Leicester, Royaume Uni
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Disabled forecolor
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01384857
Message ID:
01384857
Vues:
75
I have read the previous posts about how to change the disabled forecolor but I still have a couple of questions.
I have over ridden the OnEnabledChanged method in a custom txtBox as follows-
protected override void OnEnabledChanged(EventArgs e)
        {
            base.OnEnabledChanged(e);
            if (Enabled == false)
            {
                SetStyle(ControlStyles.UserPaint, true);
            }
            else
            {
                SetStyle(ControlStyles.UserPaint, false);
                //this.Font = new Font("Arial", 9);
            }
        }
When the txtBox is enabled, UserPaint is set to false and therefore I expected any entered text to appear as normal. In fact, the font changes to a larger size and is bold unless I uncomment the line which sets the font size above. The code in the over ride of OnPaint() works fine to change the font color and background color of the disabled txtBox.

There are two problems with a custom combobox. When I use it with items added to it programmatically, the height of the combobox is adjusted, presumably to accommodate a larger font even though I have specified the font size as above, so the text is offset upwards.

If I use the combobox with its bindingsource set and the DropDownStyle set to simple, when it is disabled the text is surrounded by a smaller grey rectangle (as it would be normally if disabled) with a thin white surround (white being the color I have set disabled backcolor to.

I would be grateful for any help.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform