0

I want my code to affect column 5 and 6 to, but everytime i add it i get an error this is wat i have so far

Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit

    If (e.ColumnIndex = 4) Then   ' Checking numeric value for Column4 only
        Dim value As String = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString()
        For Each c As Char In value
            If Not Char.IsDigit(c) Then
                MessageBox.Show("Please enter a numeric value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = String.Empty
                Exit Sub
            End If
        Next
    End If
End Sub
1
Contributor
1
Reply
6
Views
4 Years
Discussion Span
Last Post by xcrunner15
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.