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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Copy-Paste Excel multiline cells to grid

Thread ID:

Created:

Updated:

Platform:

Replies:

50525 Oct 13,2006 08:48 AM UTC Oct 17,2006 11:15 AM UTC WinForms 2
loading
Tags: GridControl
Thomas Stubbe Teglbjaerg
Asked On October 13, 2006 08:48 AM UTC

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.

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On October 17, 2006 11:15 AM UTC

I think that did the trick :-)

Thank you, Thomas.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;