Click to See Complete Forum and Search --> : Databinding to multiple combo-boxes.


KristianH
December 9th, 2002, 04:49 AM
Hi there

This is probably a newbie question but here it goes:

I have through databinding and a dataset, bound data to a combobox:

Combobox1.DataSource = Dataset1.cbdata.DefaultView
Combobox1.ValueMember = Dataset1.cbdata.cbdataIDColumn.ToString
Combobox1.DisplayMember = Dataset1.cbdata.cbdataColumn.ToString

Now the thing is this I have a second combobox (Combobox2) that I have bound to the same data:

Combobox2.DataSource = Dataset1.cbdata.DefaultView
Combobox2.ValueMember = Dataset1.cbdata.cbdataIDColumn.ToString
Combobox2.DisplayMember = Dataset1.cbdata.cbdataColumn.ToString

Now in my form, at runtime when I choose something in Combobox1, Combobox2 automatically gets the same value??? It changes as if It was set to be equal to combobox1 in some way, but I have no such code at all.

I have this problem (or feature?) when using dataview's as well.

Any help would be appreciated greatly....

Jym
December 9th, 2002, 03:48 PM
here's a suggestion, don't have a clue if it will work or not, but a suggestion just the same

combobox1.beginupdate
your code
combobox1.endupdate

combobox2.beginupdate
your code
combobox2.endupdate

takes a second of your time and it may work if not, I owe you a second :-)

KristianH
December 10th, 2002, 01:28 AM
Well unfortunatelly not, but thanx for trying.

What Im thinking is, it would probably work if I created(added) another dataadapter for the same data right??

But is this really necessary? Cause this would make the number of the dataadapters in my project to multiply quite extensivelly...well at least a few of them =P

Jym
December 10th, 2002, 07:32 AM
what happens if you use the combobox2 does combobox1 change as well ? if not then you could use the the change feature of combobox1 to set the text of combobox2 to index =1

KristianH
December 10th, 2002, 01:17 PM
Regardless of which one I change, the other one changes as well.
Setting a value in Combo1 set the same value in Combo2 and vice versa.

What I have figured so far is because I use databinding, binding to control to the same datatable I guess unifies them in some way :P

Jym
December 11th, 2002, 06:52 AM
looks like you will be adding a "2" to your code then

KristianH
December 11th, 2002, 12:46 PM
Originally posted by Jym
looks like you will be adding a "2" to your code then

Indeed! :D