BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
private void gridControl1_ClipboardPaste(object sender, GridCutPasteEventArgs e) { IDataObject data = Clipboard.GetDataObject(); if(data != null && data.GetDataPresent(typeof(string))) { string s = (string)data.GetData(typeof(string)); GridRangeInfoList rangeList; if(this.gridControl1.Selections.GetSelectedRanges(out rangeList, true)) { if(rangeList.ActiveRange.IsCells) { int row = rangeList.ActiveRange.Top; int col = rangeList.ActiveRange.Left; if(this.gridControl1.CurrentCell.IsEditing) this.gridControl1.CurrentCell.CancelEdit(); s = s.Replace("", ""); s = s.Replace("\r", ""); this.gridControl1[row, col].Text = s; e.Handled = true; e.Result = true; } } } }
if(this.gridControl1.CurrentCell.IsEditing)
this.gridControl1.CurrentCell.CancelEdit();
If you want to paste the text into an editing currentcell, the get the GridTextBoxControl from the cellrenderer, and set the text there.
if(rangeList.ActiveRange.IsCells) { int row = rangeList.ActiveRange.Top; int col = rangeList.ActiveRange.Left; s = s.Replace("", ""); s = s.Replace("\r", ""); if(this.gridControl1.CurrentCell.IsEditing) { GridTextBoxControl tb = this.gridControl1.CurrentCell.Renderer.Control as GridTextBoxControl; if(tb != null) tb.Text = tb.Text.Substring(0, tb.SelectionStart) + s + tb.Text.Substring(0, tb.SelectionStart + tb.SelectionLength ); } else { this.gridControl1[row, col].Text = s; } e.Handled = true; e.Result = true; }