this.richTextBox1.Text = " 如果只选中一个文字,如果……"; string strKey = "如果"; int start = 0; int end = this.richTextBox1.Text.Length; int index = richTextBox1.Find(strKey, start, end, RichTextBoxFinds.None); while (index != -1) { richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Underline | FontStyle.Bold); richTextBox1.SelectionColor = Color.Blue; start = index + strKey.Length; index = richTextBox1.Find(strKey, start, end, RichTextBoxFinds.None); }
查找指定文本并加粗、下划线以蓝色显示
时间: 2024-11-04 22:41:26