2013-10-30 89 views
0

enter image description hereCombobox單元格數值數據源datagridview

下面的圖像我有原因作爲組合框有三個選項。 在選擇第一個值,如內部返工,第二列負責人,這是 也組合框應填充列表集合等選擇 來自原因組合框的另一個值負責人應填充 另一個列表集合。

因爲我已經嘗試了GridView的結束編輯,它發生了顯示值,但如果在下一行我更改我的返工組合框值,責任方的先前值不保留其值。

那麼我該如何實現以防止這種情況。

所以,任何幫助表示讚賞。

回答

0

你試圖綁定其他兩個組合框的理由中選擇的值?如果是這樣的話,我會在數據網格的事件中使用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 
相關問題