首页 > 解决方案 > “System.NullReferenceException”类型的第一次机会异常

问题描述

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


    Try
        Dim i As Integer = DGV.CurrentCell.RowIndex
        Dim j As Integer = DGV.CurrentCell.ColumnIndex


        If j = 1 Then
            If DGV.Rows(i).Cells(j).Value <> Nothing Then
                Dim DT = New DataTable
                DT.Clear()
                DT = cls_account_.searsh_code(Val(DGV.Rows(i).Cells(j).Value))
                If DT.Rows.Count > 0 Then
                    DGV.Rows(i).Cells(0).Value = DT.Rows(0)(0).ToString()
                    DGV.Rows(i).Cells(2).Value = DT.Rows(0)(1).ToString()
                Else
                    DGV.Rows(i).Cells(0).Value = Nothing
                    DGV.Rows(i).Cells(2).Value = Nothing
                End If
            End If
        End If

    Catch ex As Exception
        MessageBox.Show(ex.ToString)
    End Try


End Sub

标签: visual-studio

解决方案


推荐阅读