回复 18楼DCAgile的帖子
这个问题详细考虑了一下,还需要把所有文字都重置成黑色,再搜索处理:
- private void SetSpecialStyle()
- {
- this.textControl1.SuspendLayout();
- this.textControl1.Selection.Start = 0;
- this.textControl1.Selection.Length = this.textControl1.Text.Length;
- this.textControl1.Selection.ForeColor = Color.Black;
- List<string> list = new List<string>();
- list.Add("上");
- list.Add("下");
- list.Add("重病");
- list.Add("可见");
- int index = -1;
- for (int i = 0; i < list.Count; i++)
- {
- do
- {
- index = this.textControl1.Find(list[i], index + 1, TXTextControl.FindOptions.NoMessageBox);
- this.textControl1.Selection.ForeColor = Color.Red;
- } while (index != -1);
- }
- this.textControl1.Select(this.textControl1.Text.Length-1,0);
- this.textControl1.ResumeLayout();
- }
复制代码 |