Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
800
Cut/Copy/Paste - NOT to/from Excel
posted

I need to implement Cut/Copy/Paste functionality within an application, but not for use with Excel - it is in the application only.

I'm handling the BeforePerformAction event and handling the cut/copy/paste actions, and serializing my custom type to/from the clipboard manually.  The event is firing as expected, and the clipboard operations work correctly (outside of the grid).  However, when I put the two together, it doesn't seem to be working quite right.

I first tried cancelling the action after copying to the clipboard, but if I do that, then the paste action never fires.  If I don't cancel the action after copying, then it looks like the grid is putting it's own data into the clipboard (haven't had a chance to actually look at the data here yet though).  Is there some better way to implement this?  Should I just handle the keypresses directly?  -- though if I do this, I may have problems later with toolbar menu items.

Parents
  • 469350
    Offline posted

    Hi Vineas,

    If you cancel the BeforePerformAction, then the grid will not post anything to the clipboard. You can, of course, post your own data to the clipboard, but you obviously can't expect the grid to recognize your custom data format. If you paste into the grid at this point, I would think that the BeforePerformAction would still fire, but it sounds like you are saying it does not. I guess the grid must be examining the contents of the clipboardbefore firing the BeforePerformAction and determining that there is nothing on the clipboard that the grid can recognize. This seems a little odd. One might argue that the grid should fire the event first before checking the clipboard contents. But then the event would fire when no action is really being performed, so it's a little odd either way. Changing the firing of the event now would break existing applications, so it's not something that can be changed at this point.

    On the other hand, if you don't cancel the BeforePerformAction, then the write some data to the clipboard, the grid will then go ahead and write it's data to the clipboard after you are done. The Clipboard object can store data in multiple formats, though. So you might be able to specify a format for you data that the grid does not use. I'm not sure this will work. The grid might be clearing the contents of the clipboard before it starts writing, but if that's the case, I think that would be a bug.

    Another potential solution would be to use a different event. Perhaps you can use BeforeMultiCellOperation, instead. This event might have the same issues, though, I'm not sure. 

Reply Children