public void rtbText_Hightlight(object sender, EventArgs e) { if (isHighlighting) { return; } try { isHighlighting = true; RichTextBox rtb = sender as RichTextBox; if (rtb == null) { return; } string text = rtb.SelectedText; if (string.IsNullOrWhiteSpace(text)) { return; } text = text.Trim(); var helper = new RichTextFormatterHelper(rtb); helper.Highlight(highlightText, rtb.BackColor); helper.Highlight(text, Color.BurlyWood); highlightText = text; } finally { isHighlighting = false; } }
public void rtbText_Hightlight(object sender, EventArgs e) { if (isHighlighting) return; try { isHighlighting = true; RichTextBox rtb = sender as RichTextBox; if (rtb == null) return; string text = rtb.SelectedText; if (string.IsNullOrWhiteSpace(text)) return; text = text.Trim(); var helper = new RichTextFormatterHelper(rtb); helper.Highlight(highlightText, rtb.BackColor); helper.Highlight(text, Color.BurlyWood); highlightText = text; } finally { isHighlighting = false; } }