RichText设置高亮 (未完)

  //RichText添加选区 颜色
private void ChangeColor(string text, Color color)
{
//int s = 0;
//while ((-1 + text.Length - 1) != (s = text.Length - 1 + this.txtResult.Find(text, s, -1, RichTextBoxFinds.MatchCase | RichTextBoxFinds.WholeWord)))
//{
// this.txtResult.SelectionColor = color;
//}
int s = 0;
//并上 RichTextBoxFinds.WholeWord 就没结果
while (this.txtResult.Find(text, s, RichTextBoxFinds.MatchCase) > -1)
{
s
= this.txtResult.Find(text, s, RichTextBoxFinds.MatchCase);
this.txtResult.Select(s, text.Length);
this.txtResult.SelectionColor = color;
s
++;
}

}

原文地址:https://www.cnblogs.com/shikyoh/p/2182305.html