Skip to content

Instantly share code, notes, and snippets.

Created November 8, 2010 18:46
Show Gist options
  • Save anonymous/668064 to your computer and use it in GitHub Desktop.
Save anonymous/668064 to your computer and use it in GitHub Desktop.
naughty rich text box
private void SearchAndHighlightText()
{
ordersLogRichTextBox.SelectionLength = 0;
string findStr = toolStripSearchTextBox.Text.Trim();
int startIndex = 0;
while (startIndex >= 0)
{
startIndex = ordersLogRichTextBox.Find(findStr, startIndex, RichTextBoxFinds.None);
if (startIndex > 0)
{
ordersLogRichTextBox.SelectionStart = startIndex;
ordersLogRichTextBox.SelectionLength = findStr.Length;
ordersLogRichTextBox.SelectionBackColor = Color.Yellow;
startIndex += findStr.Length;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment