Home Forums WinForms controls Xceed Grid for WinForms Grid Validation Reply To: Grid Validation

Xceed Support
Member
Post count: 5658

Hi Jeff,

Custom validation can be provided at either the row or the cell level depending on the kind of validation you want to provide. For example, for values entered into an InsertionRow, custom validation would be provided at the row level since “normally”, the user would be allowed to enter all the values in a row before they are validated. In other cases, such as when modifying existing values in the grid, validation would be done at the cell level because “normally” you would allow the user to change the value of only one cell.

Custom row validation is done using the EndingEdit and ValidationError events. In the EndingEdit event, the custom validation is provided and in the ValidationError event, you can decided if you want to allow the row to exit edit mode in the case where the values of one or more of its cells do not pass the validation process.

The row’s ValidationError event will be raised if e.Cancel is set to true in the EndingEdit event and/or if an exception is thrown in the EndingEdit event.

Custom cell validation is done using the LeavingEdit and ValidationError events. In the LeavingEdit event, the custom validation is provided and in the ValidationError event, you can decided if you want to allow the cell to exit edit mode in the case where its value does not pass the validation process.

The cell’s ValidationError event will be raised when e.Cancel is set to true in the LeavingEdit event, when an exception is thrown in the LeavingEdit event and/or when a validation exception is thrown by the underlying datasource.

If you need some code, let me know 🙂

BTW, I have completely revamped the topic on validating in the help file (for version 2.0 of the grid) which will make it alot clearer than it is now 🙂

I hope this helps!

Imported from legacy forums. Posted by Jenny [Xceed] (had 1038 views)