|
-
December 9th, 2002, 05:49 AM
#1
Databinding to multiple combo-boxes.
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....
-
December 9th, 2002, 04:48 PM
#2
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 :-)
-
December 10th, 2002, 02:28 AM
#3
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
-
December 10th, 2002, 08:32 AM
#4
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
-
December 10th, 2002, 02:17 PM
#5
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
-
December 11th, 2002, 07:52 AM
#6
looks like you will be adding a "2" to your code then
-
December 11th, 2002, 01:46 PM
#7
Originally posted by Jym
looks like you will be adding a "2" to your code then
Indeed!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|