RichTextBox color

℡╲_俬逩灬. 提交于 2019-12-12 05:49:19

问题


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


回答1:


Instead of TextChanged try it on OnKeyDown




回答2:


I presume you want to set:

richTextBox1.ForeColor = Color.AliceBlue

somewhere after your InitializeComponent(); or via the Background property in the Designer.



来源:https://stackoverflow.com/questions/12261591/richtextbox-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!