如何在没有文本背景颜色渐变的情况下禁用RichTextBox [英] How to disable RichTextBox without it's text background color fading
问题描述
在C#中,当设置属性''启用''为''false''时,文本背景变为灰色如何防止它?
In C#, When set property ''Enabled'' to ''false'', the text background turn to gray How to prevent it?
推荐答案
设置
BackColor = SystemColors.ControlLightLight;
这将修复背景颜色。我还建议把:
启用=真
ReadOnly = True
这将允许你选择文本并移动滚动条(必要时)。
Set the
BackColor = SystemColors.ControlLightLight;
That will fix the backcolor. I also recommend to put:
Enable = True
ReadOnly = True
This will allow you to select the text and move the scrollbars (when necessary).
谢谢,oarrocha
我想要RichTextBox:
1.不响应用户互动
2.保留原始的Forecolor和Backcolor
在Enabled = false之后,BackColor = SystemColors .ControlLightLight"将无法使用。
Thanks, oarrocha
I want RichTextBox:
1. do not respond to user interaction
2. keep original Forecolor and Backcolor
After "Enabled = false", "BackColor = SystemColors.ControlLightLight" will not work anymore.
谢谢,oarrocha
我想要RichTextBox:
1.不响应用户互动
2.保留原始的Forecolor和Backcolor
在Enabled = false之后, BackColor = SystemColors.ControlLightLight"将不再工作。
Thanks, oarrocha
I want RichTextBox:
1. do not respond to user interaction
2. keep original Forecolor and Backcolor
After "Enabled = false", "BackColor = SystemColors.ControlLightLight" will not work anymore.
你是对的...有了Enabled = false,它就不能按你的意愿工作了。
下面是一个示例,我在其中删除了RichTextBox和Button,并使用以下代码设置了button1.Click事件和richTextVBox1.Enter:
private void button1_Click(object sender,EventArgs e)
{
richTextBox1.BackColor = SystemColors.ControlLightLight;
richTextBox1.ReadOnly =!richTextBox1.ReadOnly;
}
private void richTextBox1_Enter(object sender,EventArgs e)
{
RichTextBox obj =(RichTextBox)sender;
if (obj.ReadOnly)GetNextControl(obj,true).Focus();
}
如果richtextbox没有滚动条,它就像你想要它,否则,用户可以控制滚动条
You are right... with Enabled = false, it won''t work as you want it.
Here is an example, where I dropped a RichTextBox and a Button, and set the button1.Click Event and richTextVBox1.Enter with this code:
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.BackColor = SystemColors.ControlLightLight;
richTextBox1.ReadOnly = !richTextBox1.ReadOnly;
}
private void richTextBox1_Enter(object sender, EventArgs e)
{
RichTextBox obj = (RichTextBox)sender;
if (obj.ReadOnly) GetNextControl(obj, true).Focus();
}
If the richtextbox doesn''t has scrollbars, it works like you want it, otherwise, the user has control of the scroll bars
这篇关于如何在没有文本背景颜色渐变的情况下禁用RichTextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!