Datagridview combo box Binding problem
-
I have two combo box in Datagridview. one is Department and Manager.Initially i'm binding All the Department and All Manager in dropdown. when select the department then manager combo should bind with selected department manager. I have done till here. but i'm facing a problem if i select one department in first row then it binds All rows with selected department's manager value. i want to bind it row wise. so every column in different row bind accroding to its department row wise. any suggestion?
Amit Agarwal
-
I have two combo box in Datagridview. one is Department and Manager.Initially i'm binding All the Department and All Manager in dropdown. when select the department then manager combo should bind with selected department manager. I have done till here. but i'm facing a problem if i select one department in first row then it binds All rows with selected department's manager value. i want to bind it row wise. so every column in different row bind accroding to its department row wise. any suggestion?
Amit Agarwal
So are you saying that you want to update the current row only? If so then you can use the grdMyGrid.CurrentRow property. When you change the value of your department dropdown, the CurrentCell property is set which in turn sets the CurrentRow property. You can then use something like
grdMyGrid.CurrentRow.Cells("ManagerCell").value = ManagerValue
If this is not what you meant then I apologise and can you post some of your code so I/we can get a better idea of the problem.
-
I have two combo box in Datagridview. one is Department and Manager.Initially i'm binding All the Department and All Manager in dropdown. when select the department then manager combo should bind with selected department manager. I have done till here. but i'm facing a problem if i select one department in first row then it binds All rows with selected department's manager value. i want to bind it row wise. so every column in different row bind accroding to its department row wise. any suggestion?
Amit Agarwal
If the relation is one-to-one, I think you can do something like this:
Me.cboDepartment.DataBindings.Clear()
Me.cboDepartment.DataBindings.Add(New Binding("SelectedValue", Me.cboManager, "SelectedValue"))I assumed that you made your combobox setting like this:
cboDepartment.ValueMember = "manager"
cboDepartment.DisplayMember = "department"cboManager.ValueMember = "manager"
cboManager.DisplayMember = "manager"So the program will read it like this:
cboDepartment.SelectedValue = cboManager.SelectedValue
cboManager.SelectedValue = cboDepartment.SelectedValueThanks, I hope this can answer your question. Best Regard, Indra Permana Rusli
- No Signature Available -