Cell leave cellvalidating touchandgodating com
Yeah, I agree with that if it is for validation only.However, for conditional formatting code, I don't see much other way for it to remain in Data Grid View's related-code (or in a class derived from Data Grid View to abstract it).
If the cell value fails validation, set the Cancel property of the System. This causes the Data Grid View control to prevent the cursor from leaving the cell.
I am currently using the Cell Validating event to prevent the cell from updating its value but I'm not able to exit the editing mode.
The cell is then waiting for a correct value and won't let the user to simply cancel&revert his action...
Now, since so many books use the Cell Validating event, I wonder if there is not any gotcha (in display for example) with using the Cell Value Changed?
I understand that the impact in performance should be irrelevant when using simple validation and conditional highlighting rules but I would as much prefer it not to run useless code everytime the user moves to another cell if it can be avoided.Here is what the validation method looks like : to get what you want.