|
-
Mar 4th, 2004, 07:25 AM
#1
Thread Starter
Member
comboboxes with same datasource
Hi guys
In my application I have some comboboxes (three to be exact) who all share the same datasource. The problem is the following: when the user clicks one of the comboboxes and selects an item, then in the other comboxes the same item also becomes selected. How can I avoid this?
I wrote the following code:
VB Code:
'creation of the dataset
Dim SQLDossier As String
SQLDossier = "SELECT * FROM basisgegevens"
ConnectionDossier.Open()
DADossier = New OleDbDataAdapter(SQLDossier, ConnectionDossier)
DADossier.Fill(DSDossier, "tblDossier")
ConnectionDossier.Close()
'filling of the comboboxes
CmbDossier1.DataSource = Me.DSDossier
CmbDossier1.DisplayMember = "tblDossier.DOSSNR"
CmbDossier2.DataSource = Me.DSDossier
CmbDossier2.DisplayMember = "tblDossier.DOSSNR"
CmbDossier3.DataSource = Me.DSDossier
CmbDossier3.DisplayMember = "tblDossier.DOSSNR"
I already tried to clear the databindings of the combobox control but that doesn't works correct.
How should I do this?
Any ideas?
thnax
-
Mar 4th, 2004, 09:08 AM
#2
Fanatic Member
i dont know what ur exact purpose is, but i think u better remove the datasource of last two combos and add the items to those combos from the 1st one.
this may help u
-
Mar 4th, 2004, 10:02 AM
#3
Thread Starter
Member
hi,
i found the solution: just add a new bindinfcontext to every combobox.
cheers
-
Mar 5th, 2004, 07:18 PM
#4
PowerPoster
Hi,
I don't understand the two previous postings.
Surely, what you should do is to create three different datasets and fill each of them from the same dataadapter. Using your originally posted code, that would be;
VB Code:
Dim SQLDossier As String
Dim dsDossier1 as New Dataset
Dim dsDossier2 as New Dataset
Dim dsDossier3 as New Dataset
SQLDossier = "SELECT * FROM basisgegevens"
ConnectionDossier.Open()
DADossier = New OleDbDataAdapter(SQLDossier, ConnectionDossier)
DADossier.Fill(DSDossier1, "tblDossier")
DADossier.Fill(DSDossier2, "tblDossier")
DADossier.Fill(DSDossier3, "tblDossier")
ConnectionDossier.Close()
'filling of the comboboxes
CmbDossier1.DataSource = DSDossier1
CmbDossier1.DisplayMember = "tblDossier.DOSSNR"
CmbDossier2.DataSource = DSDossier2
CmbDossier2.DisplayMember = "tblDossier.DOSSNR"
CmbDossier3.DataSource = DSDossier3
CmbDossier3.DisplayMember = "tblDossier.DOSSNR"
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Mar 6th, 2004, 07:47 AM
#5
Thread Starter
Member
Thanx taxes,
Yes, your solution is correct but i wanted to avoid the creation of many different datasets, because my purpose is to dynamically add controls to the form so when i can use the same dataset it's much simpler.
Thanx for the help.
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
|