How to capture copy and paste exeption

Hi,

I have a gridControl on which certain cells are of type MonthCalendar, and the CellValueType are DateTime. If I copy and paste a bunch of values (say from an excel spreadsheet) to the grid and the value going to the DateTime cell is invalid, then an exception seems to be raised and a fuzzy string "String was not recognized as a valid DateTime." shows in the DateTime cell.

My question is how I can try and catch the entire copy and paste action and give an custom error message in a messagebox if an exception is caught. Ideally, I would like to cancel the paste action if one of the cells fails.

I tried the ClipboradCopy and ClipboradPaste events, but they don't seem to be the right events to handle.

Please see attached solution and README.doc file.

Thanks very much,

Frank
UBS



CopyPasteError.zip

1 Reply

AD Administrator Syncfusion Team February 26, 2008 09:55 PM UTC

Hi Frank,

You can try using the PasteCelltext event. The PasteCelltext event is raised cell by cell as the text is being pasted. You can validate the text before grid tries to do the past on that cell. You have the option of canceling the single cell paste or cancelly the rest of the paste as well.

If you want to see the PasteCellText event raised then turn off the support for copying styles (allowing only text to be pasted and PasteCellText to be hit). To turn off style copy/paste support in a grid, turn off this flag.

Please refer the below forum thread for more details:
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=38745

Ans also you can handle the ClipboardPaste event of the grid to customize your pasting. Please refer the following forum thread for implementation.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=10877

Best regards,
Haneef


Loader.
Up arrow icon