Vb net cellvalidating e cancel

To validate data to grid cells and rows, we need to use the Validate Cell event, which will be raised by the Kettic Data Grid View when there are any changes to the current cell or when the grid cell loses input focus like.

Before we validate data to grid cell, we need to cancel the Validate Cell event to prevent the users from exiting the cell until entering a valid editor value or cancelling the edit process.

Add("Price", "Price") '---add a combobox column--- Dim combo Box Col As New Data Grid View Combo Box Column '---set the header text--- combo Box Col.

Meanwhile, we can use the Validate Row event in the same way to prevent the user from exiting the current row.

We are going through the following C# code to analyze the process of validating data in grid cell.

The Data Grid View event model is really extensive and one can take control of validation and entry by using many of these events.

Although you used Data Set as the source of your data, you also could have used generic collections if required.

Leave a Reply