【问题标题】:by Selecting datagridview combo box item, generates the txtboxcolumn value..how? in vb.net通过选择 datagridview 组合框项,生成 txtboxcolumn 值..如何?在 vb.net
【发布时间】:2013-02-21 21:13:32
【问题描述】:

您好,我想对网格视图进行如下操作,如图所示。 通过从 Item 组合框中选择项目,Unitprice 将在 Unit price txt 字段中生成。 Product 表绑定的item组合框的数据。 Item 组合框的 value 成员是 Product 字段的 Unitprice。 PLZ帮帮我。提前谢谢。

【问题讨论】:

  • 图片链接已损坏,仅供参考。
  • 只需为ComboBoxSelectedIndexChanged 事件创建一个事件处理程序,并在其中更新相应单元格的值。
  • @alldayremix 请提供一些详细信息。无法在数据网格视图事件列表中显示 SelectedIndexChanged 事件...谢谢您..
  • 它将显示在 ComboBox 事件列表中,而不是 DataGridView 事件列表中。你能post some code 显示你的控件吗?
  • 其实combo box是作为datagridview的combo box栏目使用的……那么如何找到combo box事件呢??

标签: vb.net datagrid


【解决方案1】:

您要处理DataGridViewCellValueChanged 事件。

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 

另请参阅DataGridView.CellValueChanged event reference on MSDNDataGridViewComboBoxCell class reference on MSDN 的“备注”部分。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-30
  • 2018-08-10
  • 1970-01-01
  • 2013-12-08
  • 1970-01-01
  • 1970-01-01
  • 2012-01-10
相关资源
最近更新 更多