This funtionality can be easily implemented by handling the Preview Key Down event, which will revert the row changes after pressing the Esc key.
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.
Well, after doing some research and a bit of trial and error, found out a couple of approaches. For the specific project i was working in, it was the perfect choice.
– Immediate validation: For those of you who have used dynamic regular expression validator in c#. However, one has to evaluate the pros and cons of each one.
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.
Also this approach allows the user more flexibility.In order to implement Immediate validation, the event Cell Validation must be handled Ex The validation to check if the cell is in edit mode is very important. For the Late Validation, there must be an event that is perform once the user finish entering data.In the implementation of this event, we would have to go through all the rows that have any info on them and perform the validation required, setting the appropiate error messages in the cell. 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.