When you display data entry functionality to users, you frequently have to validate the data entered into your form.The Data Grid View class provides a convenient way to perform validation before data is committed to the data store.
Private Sub Data Grid View1_Editing Control Showing(By Val sender As Object, By Val e As System. Editing Control Showing Try If UCase(s Cell Name) = "QUANTITY" Add Handler e. Key Press, Address Of Text Number Keypress End If Catch ex As Exception '...
End Try End Sub Sub Text Number Keypress(By Val sender As Object, By Val e As System.
When a user enters data in a cell under any column, I want to make sure they fill in the rest of the cells for that row.
So basically if they put data in row 0 – column 0, I want to ensure that row 0 – column 1, row 0 – column 2 and so on... I need this for validation reasons before this will be committed to the database.
The Data Grid View control of Windows Forms is a versatile control that can help you create professional-looking data entry forms.
It not only supports data binding but also provides frequently needed column types, such as combo box and button.
You can download the code that accompanies the article here.
Bipin Joshi is the proprietor of Binary Intellect Consulting, where he conducts premier training programs on . He wears many hats, including software consultant, mentor, prolific author, webmaster, Microsoft MVP, and member of ASPInsiders.
At run time, if the validation fails, the Data Grid View displays a red exclamation icon in that cell (see below).