A newer version of this page is available. Switch to the current version.

TextEdit.Paste() Method

Replaces the current selection in the text box with the contents of the Clipboard.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v19.1.dll


public void Paste()
Public Sub Paste


The Paste method pastes text from the Clipboard into the control. The text being pasted replaces the currently selected text, if any. If no text is selected, the new text is inserted at the caret position.


The following code pastes text from the Clipboard to a TextEdit control. The text is pasted only if the Clipboard contains data in text format.

If the text editor contains selected text before pasting, a message box appears asking about overriding the selection. If the end-user presses the No button, the text from the Clipboard is inserted at the end of the selection. Otherwise, the text is pasted over the selection.

private void button1_Click(object sender, System.EventArgs e) {
    if (Clipboard.GetDataObject().GetDataPresent("System.String") == true) {
        if (textEdit1.SelectionLength > 0) {
            if (MessageBox.Show("Do you want to paste over current selection?",
              "Paste Example", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) ==
                DialogResult.No) {
                textEdit1.SelectionStart += textEdit1.SelectionLength;
                textEdit1.SelectionLength = 0;
See Also