private void RegularExpression_TextChanged(object sender, EventArgs e) { // On a Paste, de-RTF the text and move the cursor back to the previous position. if (RegularExpression.UndoActionName == pasteActionString) { int cursorPosition = RegularExpression.SelectionStart; //...get the text (not the RTF) and then clear and set it, to clear formatting information string text = RegularExpression.Text; RegularExpression.Clear(); RegularExpression.Text = text; //...place the cursor at the correct position and scroll it into view RegularExpression.Select(); RegularExpression.Select(cursorPosition, 0); RegularExpression.ScrollToCaret(); } RunExpression(); }