下面的图像我有原因作为组合框有三个选项。 在选择第一个值,如内部返工,第二列负责人,这是 也组合框应填充列表集合等选择 来自原因组合框的另一个值负责人应填充 另一个列表集合。
因为我已经尝试了GridView的结束编辑,它发生了显示值,但如果在下一行我更改我的返工组合框值,责任方的先前值不保留其值。
那么我该如何实现以防止这种情况。
所以,任何帮助表示赞赏。
下面的图像我有原因作为组合框有三个选项。 在选择第一个值,如内部返工,第二列负责人,这是 也组合框应填充列表集合等选择 来自原因组合框的另一个值负责人应填充 另一个列表集合。
因为我已经尝试了GridView的结束编辑,它发生了显示值,但如果在下一行我更改我的返工组合框值,责任方的先前值不保留其值。
那么我该如何实现以防止这种情况。
所以,任何帮助表示赞赏。
你试图绑定其他两个组合框的理由中选择的值?如果是这样的话,我会在数据网格的事件中使用CellValueChanged
事件,并且可以通过编程方式建立一个列表并对其进行数据绑定。如果这是你想要做的,我会在这里发表一个例子,如果不是请澄清,所以我可以帮助。
Private Sub dgVendors_CellValueChanged(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgVendors.CellValueChanged
If dgVendors.Columns(e.ColumnIndex).HeaderText = "Reason" Then
CType(dgVendors.Rows(e.RowIndex).Cells(""), DataGridViewComboBoxCell).DataSource = Nothing
CType(dgVendors.Rows(e.RowIndex).Cells(""), DataGridViewComboBoxCell).DisplayMember = ""
CType(dgVendors.Rows(e.RowIndex).Cells(""), DataGridViewComboBoxCell).ValueMember = ""
ElseIf dgVendors.Columns(e.ColumnIndex).HeaderText = "Responsible Party" Then
CType(dgVendors.Rows(e.RowIndex).Cells(""), DataGridViewComboBoxCell).DataSource = Nothing
CType(dgVendors.Rows(e.RowIndex).Cells(""), DataGridViewComboBoxCell).DisplayMember = ""
CType(dgVendors.Rows(e.RowIndex).Cells(""), DataGridViewComboBoxCell).ValueMember = ""
End If
End Sub
如果要处理下拉列表的选择更改事件,可以使用handle the EditingControlShowing event of the DataGridView。
也有an MSDN page这可能会帮助你。 此外,请确保您更改CurrentRow
上的DataGridViewComboBoxCell
的DataSource
,而不是DataGridViewComobBoxColumn
。