We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Copy-Paste Excel multiline cells to grid

Hi,

Is it possible to copy-paste (CTRL+C/V) Excel multiline cells to a gridcontrol and keep the linebreaks ?

As it is now each line from the Excel cell is pasted into its own grid cell...

Ex.: The Excel cell could be:

abc
def
ghi

that is, 1 cell with 3 lines. Performing a CTRL+C in Excel and a CTRL+V in the gridcontrol, results in three separate grid cells:

"abc

def

ghi

Is it possible to do a copy-paste that keeps the contents in one cell ?

Regards,
Thomas.

2 Replies

AD Administrator Syncfusion Team October 14, 2006 07:21 AM UTC

Hi Thomas,

You could try handling ClipboardPaste event as shown in the following code:


gridControl1.ClipboardPaste+=new GridCutPasteEventHandler(gridControl1_ClipboardPaste);
private void gridControl1_ClipboardPaste(object sender, GridCutPasteEventArgs e)
{
GridCurrentCell cc=this.gridControl1.CurrentCell;
if (cc.HasCurrentCell)
{
DataObject data = (DataObject) Clipboard.GetDataObject();
if(data.GetDataPresent(DataFormats.Text))
{
string s = (string)data.GetData(DataFormats.Text);
this.gridControl1[cc.RowIndex, cc.ColIndex].Text = s;
e.Handled = true;
}
}
}


Please let me know if you need further assistance.

Regards,
Srividhya R


AD Administrator Syncfusion Team October 17, 2006 11:15 AM UTC

I think that did the trick :-)

Thank you, Thomas.

Loader.
Live Chat Icon For mobile
Up arrow icon