The cell edit canceling is done in cell’s LeavingEdit event handler by setting the “e.Cancel = true” and then in the cell’s ValidationError event handler I set the e.CancelEdit to false. I would expect here that the cell being prevented from leaving the edit mode, and no collapse action to occur because in the documentation it says that “Setting e.CancelEdit to false in the ValidationError event will
prevent the cell from leaving edit mode in the case where the its value fails
the validation process.“
But as I said, on the first click on the minus sign, nothing happen, no collapse, nor exception being thrown. On the second click on the minus sign, the debugger enters in the cell’s LeavingEdit event handler, the e.Cancel is set on true as it should, then it enters into the cell’s ValidationError event handler where e.CancellEdit is set on false. The “e.CancelEdit = false;” is the single line of code in the cell’s ValidationError event handler. The e.Exception field has the following exception set (which I suppose is the correct behavior) “The cell’s attempt to leave edit mode has been cancelled.“.
So far, so good, the problem is that after the code exits from the cell’s ValiationError event handler, the error with the stack trace mentioned in my first post is being thrown. The exception text is “The value of a cell or one of the cells in a DataRow failed the validation process.” and the inner exception is the same as e.Exception was in the ValidationError (“The cell’s attempt to leave edit mode has been cancelled.“).I don’t know why this inner exception is not swallowed as I think it should be and why a collapse action is allowed if the ValidationError->e.CancelEdit=false should prevent the cell from leaving the edit mode as the documentation says.
Anyone can help please?
Imported from legacy forums. Posted by bogdip (had 709 views)