List strWarn=new List();//定义一个泛型,可以自由的添加字段
private void WarnInfo(string str)
{
strWarn.Add(str);
for (int i = 0; i < strWarn.Count; i++)
{
int lenth = richTextBox1.Text.Length;
richTextBox1.AppendText(strWarn[i]);
if (richTextBox1.Lines[i].Contains("一级警告"))
{
for (int j = 0; strWarn[i][j] != '\n'; j++)//对于这一行来说\n是结尾
{
richTextBox1.Select(lenth + j, 1);//一个一个的选择然后改变颜色
richTextBox1.SelectionColor = Color.Red;
}
}
if (richTextBox1.Lines[i].Contains("二级警告"))
|