C cellvalidating cancel
If the event handler for the Cell Validating event finds that the value is an empty string, the Data Grid View prevents the user from exiting the cell until a non-empty string is entered.
However, pressing the Esc key in this situation will revert the initial value of the cell and it will close the editor. The Row Validating event has a slightly different behavior.
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.
Thus, you will be able to change the behavior of all keys.
The hurdle here is the requirement for predefining each one of the commands.
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).