问题
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