【发布时间】:2018-08-09 14:49:10
【问题描述】:
按照我前面的question 关于根据comboboxcolumncells 更改列单元格上的值,现在我遇到了以下问题。我的事件触发,但我在DataBindings 行收到以下错误消息:无法链接数据源中的属性或函数“值”。参数名称:dataMember。除此之外,其他列的值没有改变。在这种情况下我该怎么办?
Private Sub dgv_CellValueChanged(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles dgv.CellValueChanged
Dim r As Integer = e.RowIndex
Dim c As Integer = e.ColumnIndex
Try
If r > -1 Then
If c = 15 Then
dgv.DataBindings.Add("Text", dt, "value", False, DataSourceUpdateMode.OnPropertyChanged) 'I wanted to overwrite cells with the value associated with the code of the comboboxcell
Dim col_div_cell_value As Object = dt.Tables(0).Columns("value")
dgv.CurrentRow.Cells("col_1").Value = col_div_cell_value.Value()
dgv.CurrentRow.Cells("col_2").Value = (col_div_cell_value * col_3)
End If
End If
Catch ex As Exception
MsgBox("ERROR: " & ex.Message, MsgBoxStyle.Information)
End Try
End Sub
dt 的结构:这个datatable 被记入comboboxcell,它显示"code" 和我想在该行的其他列单元格上写入的值(Col_1 和 Col_2 ),是与该代码关联的"value":
code | date | value
---------------------
A 12/06 100
B 12/06 200
...
提前致谢
【问题讨论】:
标签: .net vb.net data-binding datatable datagridviewcomboboxcell