Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void HighlightWord(RichTextBox rtb, string word, Color color) {
- int startIndex = 0;
- while (startIndex < rtb.TextLength) {
- int wordStartIndex = rtb.Find(word, startIndex, RichTextBoxFinds.None);
- if (wordStartIndex != -1) {
- rtb.SelectionStart = wordStartIndex;
- rtb.SelectionLength = word.Length;
- rtb.SelectionColor = color;
- }
- else
- break;
- startIndex += wordStartIndex + word.Length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement