【发布时间】:2010-11-30 22:44:40
【问题描述】:
我在 vb.net 中使用网格视图。
这是代码...
If Not DataGridView1.SelectedRows.Count = 0 Then
i = DataGridView1.SelectedRows(0).Index
If DataGridView1.Rows(i).Cells(0).Value <> Nothing Then
namebox.Text = Trim(DataGridView1.Rows(i).Cells(0).Value)
salarybox.Text = DataGridView1.Rows(i).Cells(1).Value
End If
End If
现在如果单元格中没有任何内容,那么它将显示异常......
像这样……
Operator '<>' is not defined for type 'DBNull' and 'Nothing'.
这是在更改选定单元格时将调用代码。
我试图获取所选单元格的值并将其放入一个文本框中。
【问题讨论】: