Changing the colour of a disabled textBox

haroldjclements

Freshman
Joined
Jun 13, 2004
Messages
46
Hello,

I think this will be an easy question to answer for an experienced .NET programmer.

Can you change the colour of the text in a textbox that disabled? I have a light grey background to the text box which makes the text very difficult to read.

Any help will be very much appreciated,

Harold Clements
 
haroldjclements said:
Hello,

I think this will be an easy question to answer for an experienced .NET programmer.

Can you change the colour of the text in a textbox that disabled? I have a light grey background to the text box which makes the text very difficult to read.

Any help will be very much appreciated,

Harold Clements

Hi Harold

Instead of setting the TextBox to Disabled, set it to ReadOnly, then you can set the BackColor of the TextBox to White and the ForeColor to Black and it will look like a "Normal" TextBox.
 
ReadOnly would be preferable if you want the user to be able to copy the text (or if you dont care). However, if, for some reason, you don't want the user the be able to copy text, I don't believe that the .Net framework provides a method for changing the text color, but since it will let you change the backcolor, why don't you set the backcolor to the default disabled backcolor (SystemColors.Control) when it is disabled, so that the user has a visual cue that it is disabled and the text is readable.

[Edit]Also, I don't know why you are changing the color of the textbox, but there is disagreement between programmers as to whether or not it is okay to override a user's color preferences. If your situation really warrants it, go ahead and change the back color. If it isn't really necessary, though, you might want to think twice before changing the colors around.[/Edit]
 
Yeah... I think you can allways override the paint of the control evaluating if it's desabled... but I stick with marble_eater (nice nick) :D

Windows (and all other OS's) stand on top of standards.
Layout standards (in this case for software) are usefull so anyone who is used to work on an application, can jump to another one with no pain besides the business logic of it...

As everyone is used to have a grey background as standard for a desabled control, change it to yellow will be a bit confusing... don't you think?

Alex :p
 
Back
Top