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

How to capture copy and paste exeption

Thread ID:

Created:

Updated:

Platform:

Replies:

71992 Feb 25,2008 04:28 PM UTC Feb 26,2008 09:55 PM UTC WinForms 1
loading
Tags: GridControl
Frank
Asked On February 25, 2008 04:28 PM UTC

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

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


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.

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

;