Hi,
I'll get straight to my problem - I'm currently coding in Visual Studio.
I have a table (countries) with the columns ID | Name. The table is filled with around 28 records.
I also have a form with 4 combo boxes (set up as 1,2,3 & 4) that I want the user to select. These combo boxes will display the names from the table countries. I then want to use the selected names in the combo boxes to Insert into their corresponding ID into another table. For example England would have the ID 1, USA the ID 2 etc.
So, is it possible to have separate combo boxes that will give separate ID values but using the same table? At the moment I can't seem to find a solution.
Eventually the form will have more than 4 combo boxes so I don't want to use separate bindingsources for each combo box.
Thanks,
Andy.
Multiple Combo BoxesUsing multiple combo boxes from the same table
Page 1 of 1
5 Replies - 1535 Views - Last Post: 30 April 2010 - 01:54 PM
Replies To: Multiple Combo Boxes
#2
Re: Multiple Combo Boxes
Posted 30 April 2010 - 03:22 AM
Just to add:
Currently when I select a value from the first combo box, all the other boxes change to the same value (I guess this is because they are looking at the same bindingsource?).
Currently when I select a value from the first combo box, all the other boxes change to the same value (I guess this is because they are looking at the same bindingsource?).
#3
Re: Multiple Combo Boxes
Posted 30 April 2010 - 03:39 AM
Hi,
you can use a copy of the data source, it's something like:
assuming your datasource is (dt)
you can use a copy of the data source, it's something like:
assuming your datasource is (dt)
ComboBox1.DataSource = dt.Copy() ComboBox2.DataSource = dt.Copy() ComboBox3.DataSource = dt.Copy()
#4
Re: Multiple Combo Boxes
Posted 30 April 2010 - 03:58 AM
ahmad_511, on 30 April 2010 - 02:39 AM, said:
Hi,
you can use a copy of the data source, it's something like:
assuming your datasource is (dt)
you can use a copy of the data source, it's something like:
assuming your datasource is (dt)
ComboBox1.DataSource = dt.Copy() ComboBox2.DataSource = dt.Copy() ComboBox3.DataSource = dt.Copy()
Thanks for your reply.
I've tried what you have suggested using
ComboBox1.DataSource = WCDataSet.tblCountries
However I get this in my combo boxes.
System.Data.DataRowView
I know you mentioned DataSource (not DataSet) in your post. How do I set the DataSource as the tblCountries.
Thanks in advance.
Andy,
This post has been edited by Andy C: 30 April 2010 - 03:58 AM
#5
Re: Multiple Combo Boxes
Posted 30 April 2010 - 04:04 AM
Just answering my own question here.
I've used.
Seems to work fine.
Thanks for your post, it was most helpfuly!
Andy.
I've used.
ComboBox1.DataSource = WCDataSet.tblTeams.Copy
ComboBox1.DisplayMember = "tCountry"
Seems to work fine.
Thanks for your post, it was most helpfuly!
Andy.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|