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

Copy/Paste issue

Hi, I am having a problem with pasting into the Grid. I am coping several different columns from the source, but Ctrl-V pastes everything into the first column in the grid, while if I paste it into excel it works fine. What can I do to make sure it splits up the data into different column? Is there a feature similar to "Text to Columns" option in Excel?

5 Replies

AD Administrator Syncfusion Team November 17, 2004 03:17 PM UTC

If you are copying this from a grid to a grid, it should work. If you are having a problme with this, can you post a sample showing it or tell us how to see it in one of our samples. If you are copying it from outside the grid, the default grid implementation expects tab delimited data (tabs between columns and newlines between rows). If you have some other kind of data, then you would have to handle the ClipboardPaste event, amd do the paste yourself.


AD Administrator Syncfusion Team November 17, 2004 04:13 PM UTC

I am actually copying from an outside source, which is a table on a website. The rows are recognized just fine. As for columns, there are empty spaces between the columns(not tabs), but I guess that''s not enough to defferentiate between them. Can you give me some examples of how to handle it through a ClipboardPaste event, I am kind of new to all of this. Thank you for your help.


AD Administrator Syncfusion Team November 17, 2004 05:35 PM UTC

Take a look at this forum thread. It may be enough to get you going. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9389


AD Administrator Syncfusion Team November 17, 2004 07:34 PM UTC

I''ve looked through the code, but I am not sure how this is helpful. Is it possible, let''s say, to replace the empty spaces separating columns with tabs while the data is in the clipboard so it will paste it into separate columns instead of one? I don''t want to take the data in the first column and manually parse it to divide up into the proper columns after it''s been pasted. Thanks again.


AD Administrator Syncfusion Team November 17, 2004 08:11 PM UTC

You can use the code from teh sample to get teh string, and then do your replacement and put it back on teh clipboard and then let teh grid continue handling the paste at that point.
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));
		s = s.Replace(" ", "\t");
		Clipboard.SetDataObject(s);
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon