troubleshooting Question

Settting select cell value from a datagridview

Avatar of mgmhicks
mgmhicks asked on
.NET ProgrammingVisual Basic.NETVB Script
1 Comment1 Solution832 ViewsLast Modified:
I have the following code.  What I am trying to do is after a cell value has changed from one of these 3 columns, I want to validate data.  If it comes back false I want to go back to the cell that just failed validation.  I have the following code and the validation works, however I cant seem to get it to go back to the unvalidated cell.

thanks in advance

Here is the code

 Private Sub dgv1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv1.CellValueChanged
        Dim myError As String = ""
        If isLoading Then
            If e.ColumnIndex = 5 Then
            ElseIf e.ColumnIndex = 6 Then

                If ValidateColumn(dgv1(e.ColumnIndex, e.RowIndex).Value.ToString, e.ColumnIndex, myError) Then
                    dgv1.CurrentCell = dgv1.Rows(e.RowIndex).Cells(e.ColumnIndex)
                    'dgv1.Rows(e.RowIndex).Cells(e.ColumnIndex).Selected = True
                    Exit Sub
                End If

            ElseIf e.ColumnIndex = 8 Then
            End If
        End If

    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros