I am able to validate my value properly but when I try to change it to something valid I get a Data Error. You should never attempt to change the cell value in the handler for this event, because unless you cancel the event (in which case the user is stuck in edit mode), the cell value is set to the value from the editing control immediately after the event finishes.
This, therefore, undoes any action you perform in the handler.
Editing Control Showing 'Cache the edit control text Me.cached Edit Text = e. Text End Sub Private Sub Handle Dgv Cell Validating(sender As Object, e As Data Grid View Cell Validating Event Args) Handles Dgv.
Cell Validating 'Ensure that the edit control exists If (Not Me. Editing Control Is Nothing) Then 'Validate the edit If (Not valid) Then Me.
Is there a way to change the dgv cell Style Format and cell Tag from within the Cell Validating event?
This will prevent duplication if the handler is already attached to the event, but will have no effect otherwise.Control, Data Grid View Text Box Editing Control) .Text = "1/1/2001" End With End If End Sub Private Sub Handle Dgv Editing Control Showing(sender As Object, e As Data Grid View Editing Control Showing Event Args) Handles Dgv.For more information, see the example code in the Data Grid View Combo Box Editing Control class overview.which causes an Invalid Cast Exception (didn't check that could only be an integer).