标签:cti col rtx vat sele red sea while img
RichTextBox 中打开文件并显示,按查找,匹配所有相同的文字并红色显示:
private void BtnSearch_Click(object sender, EventArgs e) { string strKeyWords = txtKeyWords.Text.Trim(); //int intFirst = rtxtbox.Text.IndexOf(strKeyWords); //if (intFirst >= 0) //{ // rtxtbox.Select(intFirst, strKeyWords.Length ); // rtxtbox.SelectionColor = Color.Red; //} Regex regex = new Regex(strKeyWords); Match match = regex.Match(rtxtbox.Text); while (match.Success) { rtxtbox.Select(match.Index, strKeyWords.Length); rtxtbox.SelectionColor = Color.Red; match = regex.Match(rtxtbox.Text, match.Index + strKeyWords.Length); } }
标签:cti col rtx vat sele red sea while img
原文地址:https://www.cnblogs.com/wenjie0904/p/9610918.html