沐风心扬C#编程速查系列之RichTextBox单行文本颜色设置

富文本框以指定颜色输出指定文字
//输出消息
private void OutMsg(RichTextBox rtb, string msg, Color color)
{
rtb.Invoke(new EventHandler(delegate
{
rtb.SelectionStart = rtb.Text.Length;//设置插入符位置为文本框末
rtb.SelectionColor = color;//设置文本颜色
rtb.AppendText(msg + "\r\n");//输出文本,换行
rtb.ScrollToCaret();//滚动条滚到到最新插入行
}));
}