datagridview cell null值错误

时间:2015-11-23 10:03:42

标签: vb.net datagridview

如果未输入datagridview单元格中的值,则现在只能处理错误。谁有更好的解决方案?

Dim senderGrid = DirectCast(sender, DataGridView)

If TypeOf senderGrid.Columns(e.ColumnIndex) Is DataGridViewButtonColumn _
        AndAlso e.RowIndex >= 0 _ 
        AndAlso senderGrid.Columns(e.ColumnIndex).Name = "Add" Then

    Dim _status As Integer

    Try
        _status = Math.Abs(CInt(dgv6.Item("dgv6_Aktivno", dgv6.CurrentRow.Index).Value))
    Catch ex As Exception
        _status = 0
    End Try

    Dim _id As Integer
    Try
        _id = dgv6.Item("dgv6_id", dgv6.CurrentRow.Index).Value
    Catch ex As Exception
        _id = 0
    End Try

End if

0 个答案:

没有答案