However, the user may prefer to validate all the data cells in a row at once.
This scenario can be achieved by using the Row Validating event, which is fired when the user tries to change the current row (changing to another row or when the control loses focus).
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...
You can also build this example in Visual Studio by pasting the code into a new project.
Also see How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio.
When the validation fails, the editor is closed, but the user cannot change the current row in the grid until a valid cell value is entered.
For more information about handling events, see NIB: Consuming Events.How can i prevent the validation from taking place when the user hits the cancel button?The validation triggers a messagebox which is always shown even if the user wants to cancel editing/adding an object because the validating happens before the button-click.Canceling this event prevents the user from exiting the cell until a valid value is entered or the edit process is canceled (via Esc key).The Data Bound Item will be updated only if the cell is validated.