如何改变一个残疾人TextBox的字体颜色? [英] How to change the font color of a disabled TextBox?
问题描述
有谁知道哪个属性设置为禁用的控件的文本颜色?
我要在显示文本框禁用一些文字,我想设置它的颜色为黑色。
Does anyone know which property sets the text color for disabled control? I have to display some text in disabled TextBox and I want to set its color to black.
谢谢!
推荐答案
注意:请参阅下面的,因为它确定了prerequisite猎豹的回答让这个解决方案工作。设置背景色
的文本框
。
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
.
这是一个有点棘手更改文本的颜色禁用文本框
。我想你也许不得不继承并重写的OnPaint
事件。
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
.
另一种简单的替代方法是使用而不是 A 标签的
文本框
。
Another simple alternative is to use a Label
instead of a TextBox
.
这篇关于如何改变一个残疾人TextBox的字体颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!