Cellvalidating example

The Cell Validating event only fires when losing input focus (before leaving the current cell) or when Gc Multi Row validates.

The default key setting assigns end edit without leaving the current cell action to the "Enter" key.

The Data Grid View control of Windows Forms is a versatile control that can help you create professional-looking data entry forms.

What's the best place to implement validation logic code and conditional formatting code for a Data Grid View?

If the focus is moved to a cell in the same row, then no other events occur.

If the focus is moved to a cell in another row, then both Row Validating and Row Validated are fired, containing the whole row data, including the new and the old values of the edited cells.

In general, it is better to use the Cell Parsing event whenever you need to convert/change the value in a cell.

Handle the Cell Validated event to perform post validation processing.

Canceling this event cancels the changes to the current cell.

From within that event, you can indicate that the user's value is invalid by setting the Error Text value of the cell or row.

To perform any custom validation on the cell or row being edited, you can use the Cell Validating and Row Validation events, respectively.