C cellvalidating event
If you want to validate the data cell by cell, the former event is useful where you want to validate the data for the entire row at once then the later event is handy.
In your example, you use the Cell Validating event, as shown below: Here, you want to ensure that the length of the new Customer ID is at least five characters.
At this point the user is not allowed to cancel the performed changes, pressing the Esc key.
The validation events are meant to support the data validation of the user input.
Let's assume that the If the user enters empty string for a specific cell and tries to navigate to another row, the validation fails and the Error Text is displayed on the corresponding row.
The Data Bound Item will be updated only if the cell is validated.
This funtionality can be easily implemented by handling the Preview Key Down event, which will revert the row changes after pressing the Esc key.
The Cell Validating event occurs always before the Cell Validated event when the edited cell is about to lose its focus.
If the focus is moved to a cell in the same row, then no other events occur.
SOLUTION To achieve data validation prior the row is committed, you can handle the Cell Validating event, which is raised by the control when the current cell changes or when it goes out of edit mode.
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).