富文本框颜色 [英] RichTextBox color
本文介绍了富文本框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户将文本输入 RichTextBox 控件时,我希望文本的颜色为例如绿色.我使用某事:
I wish color of text was e.g green when user inputs it into RichTextBox control. I use sth like:
private void richTextBox1_TextChanged(object sender, CancelEventArgs e)
{
RichTextBox richTextBox1 = sender as RichTextBox;
richTextBox1.SelectionBackColor = Color.AliceBlue;
}
但它导致第一个符号在正常背景中,并且从第二个符号开始整个输入文本是蓝色的:
But it cause that first sign is in normal background, and starting from second sign whole eneterd text is blue:
图案(大写是彩色的):输入的文本
pattern(upper case is colored): eNTERED TEXT
推荐答案
在 OnKeyDown 上尝试代替 TextChanged
Instead of TextChanged try it on OnKeyDown
这篇关于富文本框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文