Home Forums WinForms controls Xceed Grid for WinForms WinTextBox paste Reply To: WinTextBox paste

User (Old forums)
Post count: 23064

You will need to retrieve the text from the WinTextBox editor that is used by the cell, and insert the string from the clipboard at the position of the caret.


    private void pasteToolStripMenuItem_Click( object sender, EventArgs e )
      WinTextBox textBox = gridControl1.CurrentCell.CellEditorControl as WinTextBox;
      if( textBox != null )
        int selectionStartIndex = textBox.TextBoxArea.SelectionStart;
        string text = textBox.TextBoxArea.Text.Remove( selectionStartIndex, textBox.TextBoxArea.SelectionLength );
        string clipboard = Clipboard.GetText();
        textBox.TextBoxArea.Text = text.Insert( selectionStartIndex, clipboard );

Note however that you may need to add some validation so it will not throw any exception in all the scenarios you want it to support.

Imported from legacy forums. Posted by André (had 1686 views)