Datagridview cellvalidating change cell value
To customize the conversion of a formatted, user-specified value into an actual cell value, handle the Cell Parsing event.
For more information about handling events, see NIB: Consuming Events.
By default, the Data Grid View control will attempt to convert a cell's value into a format suitable for display.
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.
For a complete explanation of this code example, see Walkthrough: Validating Data in the Windows Forms Data Grid View Control.
You can validate data by handling the Cell Validating event, which is raised by the Data Grid View when the current cell changes.
In this walkthrough, you will retrieve rows from the column and tries to leave the cell, the Cell Validating event handler will examine new company name string to make sure it is not empty; if the new value is an empty string, the Data Grid View will prevent the user's cursor from leaving the cell until a non-empty string is entered.