FormatException: "Input string was not in a correct format" error is thrown when I enter "abc" into a float column.
None of the cell events is catching this exception including CellDataError, CellChange, Before/AfterCellUpdate, BeforeCellDeactivate, AfterExitEditMode.
The error kicks out directly to Application.Run in the Main() and crashes the app.
I don't think this should be the intended behavior. At any rate, any data exception should be trappable and not crash the app.
Is there an event or setting that I am missing?
I need to fix this asap. Any help greatly appreciated.
I tried this out and almost all of the events you listed here fire. My guess is that you are running without the Debugger attached or maybe you have a try...catch block around your Main method so you are catching all exception.
Mike,
I was running with debugger set to break at all CLR exceptions. I unchecked that and now it is breaking at CellDataError. However, I am getting a popup :
"Error performing Paste operation. Further information : Unable to convert the value 'abc' to the column's data type: Illegal data value.
Continue with the remaining cells?"
Is there any way I can suppress this popup? I don't want the user to click a 100 popups if there are 100 errors. I would rather just highlight the bad cells and show one popup. I have tried setting e.RaiseErrorEvent = false in CellDataError with no effect.
Thanks,Chandra
Hi Chandra,
What you can do is handle the Error event (not CellDataError).
Examine e.MultiCellOperationErrorInfo.DataErrorInfo to determine what Exception was raised so you know what the error was.
You can set e.Cancel to true to cancel the display of the default error message dialog. And you can set e.MultiCellOperationErrorInfo.Action to determine what the grid does next.
Hi Mike,
Thanks for the reply. This was what I needed.
Chandra