private void SourceText_TextChanged(object sender, EventArgs e) { // On a Paste, de-RTF the text and move the cursor back to the previous position. if (SourceText.UndoActionName == pasteActionString) { int cursorPosition = SourceText.SelectionStart; //...get the text (not the RTF) and then clear and set it, to clear formatting information string text = SourceText.Text; SourceText.Clear(); SourceText.Text = text; //...place the cursor at the correct position and scroll it into view SourceText.Select(); SourceText.Select(cursorPosition, 0); SourceText.ScrollToCaret(); return; } // We can't run the expression here. When the expression runs we immediately // highlight all matches and make a selection, which means each character you type // will go after the selection we make instead of the cursor position you had in mind. }
private void ClearBtn_Click(object sender, EventArgs e) { SourceText.Clear(); BackText.Clear(); Commparelabel.Text = "---"; }