Datagridview cellvalidating date

If you want to validate the data cell by cell, the former event is useful where you want to validate the data for the entire row at once then the later event is handy.

In your example, you use the Cell Validating event, as shown below: Here, you want to ensure that the length of the new Customer ID is at least five characters.

datagridview cellvalidating date-25

It not only supports data binding but also provides frequently needed column types, such as combo box and button.

You do this by using the Formatted Value property of the Data Grid View Cell Validating Event Args parameter.

This property returns the new value entered in the cell.

If it is less than five characters, you set the Error Text property of that cell to some error message.

Notice how the Column Index and Row Index properties of Data Grid View Cell Validating Event Args parameter are used.

At run time, if the validation fails, the Data Grid View displays a red exclamation icon in that cell (see below).

Hovering the mouse pointer on the icon displays the Error Text that you set earlier.

You'll be able to ask any tech support questions, or chat with the community and help others.

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


  1. I was relieved that I was well within this timeframe and seeing as I didn't activate my account I assumed that my refund of £30 would be made within 24hrs.

Comments are closed.