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

Paste into Grid without ColHeaders...

Hello! We have a grid an we are allowing to copy cells from the Grid. We include the colheaders using: grid.Model.CutPaste.ClipboardFlags |= GridDragDropFlags.ColHeader; We use the colheaders to be able to paste nicely in Excel. But when we are going to paste into our grid we would like to eliminate the ColHeaders that were copied before. How can we achieve that? Thanks in advance Jorge

2 Replies

AD Administrator Syncfusion Team January 23, 2004 01:22 PM UTC

When you go to paste into the grid, how is the grid suppose to know what was copied onto the clipboard (from wherever it was copied) actually contains headers. So your user copies just a group of cells, and then pastes them back into the grid some. The default grid behavior does not mark cells that get pasted as being header cells. It just puts the values of the cells onto the clipboard. So, using the default behavior there is no perfect way to look at the clipboard contents and know some of the cells came from a header. So, to handle things in a fool proof way, I think the solution would be to place a custom DataObject on the clipboard. You custom dataobject would somehow distinguish between header cells and other cells. To do this, you could handle the Model.ClipboardCopy event and create your custom object there and put it on th e clipboard. Then you could handle the Model.ClipboardPaste event to paste this custom object back into the grid. Here is a link to some sample code that uses the ClipboardCopy event to manage special behavior. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9906 Here is a link to a forum post using ClipboardPaste. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9389 Now if you want to make assumptions like the first row always contains headers, this would simplify what you need to do, and you could probably get away with using the standard support for Copy and only handle the Paste to throw away the first row. But I am not sure if this assumption will serve your needs. If you get stuck doing this, this is the kind of your can submit as a Direct Trac support incident and we can probably get you over the task.


AD Administrator Syncfusion Team January 23, 2004 01:44 PM UTC

Hi, Actually we can paste to the grid data copied from excel, so We cannot assume the first row is always the header. Thinking on that I think the workaround I am going to use is to have a flag in true when we copy something from our grid and keep the string copied. So when pasting we check both variables and delete the first row if necessary. Thanks a lot for your help, Jorge

Loader.
Live Chat Icon For mobile
Up arrow icon