if (counter == 0)
textBox2.Text += "ERROR: the item in the " + j + "th row is wrong" + Environment.NewLine;
如何在TextBox中显示j变量Red?
答案 0 :(得分:3)
您只需更改整个字体的颜色即可。使用textBox2.ForeColor = Color.Red
或使用RichTextBox
答案 1 :(得分:2)
首先,将其设为富文本框而不是常规文本框。
然后
Font fnt=new Font("Verdana", 8F, FontStyle.Italic, GraphicsUnit.Point);
string mystring=@" " + j + "th";
if (richTextBox1.Find(mystring)>0)
{
int my1stPosition=richTextBox1.Find(mystring);
richTextBox1.SelectionStart=my1stPosition;
richTextBox1.SelectionLength=mystring.Length;
richTextBox1.SelectionFont=fnt;
richTextBox1.SelectionColor=Color.CadetBlue;
}
答案 2 :(得分:0)