if the user enters a filter string in my RichTextBox I want the string OR + AND to be colorized.
Below code works until the user goes back with the cursor in order to delete/change code. Then some chars after the cursor gets automatically selected and overwritten, what I do not want. How to change this behaviour, any idea?
public Regex keyWords = new Regex("AND|OR");
private void rowfilterRichTextBox_TextChanged(object sender, EventArgs e)
int selPos = rowfilterRichTextBox.SelectionStart;
foreach (Match keyWordMatch in keyWords.Matches(rowfilterRichTextBox.Text))
rowfilterRichTextBox.SelectionColor = Color.Blue;
rowfilterRichTextBox.SelectionStart = selPos;
rowfilterRichTextBox.SelectionColor = Color.Black;