我想从具有所选行的 datagridview 的表中返回一个值
TextBox8.Text = Me.DataGridView1.CurrentRow.Cells("Vend Price").ToString
vend price 代表所需的列名。
我收到错误消息:
Object reference not set to an instance of an object.
现在我做错了什么?
ps 是否可以从数据网格的已删除列中返回一个值,或者我将直接从表中返回?
更完整的代码如下:
Private Sub MainMenu_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.ProductsTableAdapter.Fill(Me.MisuDBDataSet.Products)
End Sub
Private Sub Button15_Click(sender As System.Object, e As System.EventArgs) Handles Button15.Click
If Me.DataGridView1.CurrentRow.Cells("Vend Price").Value.ToString Is Nothing Then
'Do nothing
Else
Label13.Text = Me.DataGridView1.CurrentRow.Cells("Vend Price").Value.ToString
End If
End Sub