
您好,我想在网格视图上执行如下操作,如图所示。通过从 Item 组合框中选择项目,Unitprice 将在 Unit price txt 字段中生成。Product 表绑定的item组合框的数据。Item 组合框的 value 成员是 Product 字段的 Unitprice。PLZ帮帮我。提前谢谢。
您要CellValueChanged处理DataGridView.
Private Sub CellValueChanged(ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles DataGridView1.CellValueChanged
' Update the unit price column whenever the value of the item cell changes.
If DataGridView1.Item(e.ColumnIndex, e.RowIndex) == DataGridView1.Item("Item", e.RowIndex) Then
DataGridView1.Item("Unit Price", e.RowIndex).Value = DataGridView1.Item(e.ColumnIndex, e.RowIndex).Value
End Sub
另请参阅 MSDN 上的DataGridView.CellValueChanged 事件参考和 MSDN上DataGridViewComboBoxCell 类参考的“备注”部分。