Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the font color of a disabled TextBox?

Tags:

c#

winforms

Does anyone know which property sets the text color for disabled control? I have to display some text in a disabled TextBox and I want to set its color to black.

like image 961
Niko Gamulin Avatar asked Nov 09 '08 17:11

Niko Gamulin


People also ask

How do you change the Font color for disabled input?

Approach: With adding basic CSS property we are able to change the font-color of a disabled input. The disabled input element is unusable and un-clickable. This is a boolean attribute. Here using the color property of input we can change the font-color of this disabled input element.

What is the color of disabled textbox?

The background color for a disabled input in chrome is rgb(235,235,228) if that helps .. In firefox the disabled input background-color is F0F0F0.


1 Answers

NOTE: see Cheetah's answer below as it identifies a prerequisite to get this solution to work. Setting the BackColor of the TextBox.


I think what you really want to do is enable the TextBox and set the ReadOnly property to true.

It's a bit tricky to change the color of the text in a disabled TextBox. I think you'd probably have to subclass and override the OnPaint event.

ReadOnly though should give you the same result as !Enabled and allow you to maintain control of the color and formatting of the TextBox. I think it will also still support selecting and copying text from the TextBox which is not possible with a disabled TextBox.

Another simple alternative is to use a Label instead of a TextBox.

like image 56
Eric Schoonover Avatar answered Oct 23 '22 10:10

Eric Schoonover