Multiple Combo Boxes

Using multiple combo boxes from the same table

Page 1 of 1

5 Replies - 1535 Views - Last Post: 30 April 2010 - 01:54 PM Rate Topic: -----

#1 Andy C  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 27-January 09

Multiple Combo Boxes

Posted 30 April 2010 - 02:29 AM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: Multiple Combo Boxes

#2 Andy C  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 27-January 09

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?).
Was This Post Helpful? 0
  • +
  • -

#3 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 125
  • Posts: 704
  • Joined: 28-April 07

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)
ComboBox1.DataSource = dt.Copy()
ComboBox2.DataSource = dt.Copy()
ComboBox3.DataSource = dt.Copy()


Was This Post Helpful? 2
  • +
  • -

#4 Andy C  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 27-January 09

Re: Multiple Combo Boxes

Posted 30 April 2010 - 03:58 AM

View Postahmad_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)
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

Was This Post Helpful? 0
  • +
  • -

#5 Andy C  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 27-January 09

Re: Multiple Combo Boxes

Posted 30 April 2010 - 04:04 AM

Just answering my own question here.

I've used.
        ComboBox1.DataSource = WCDataSet.tblTeams.Copy
        ComboBox1.DisplayMember = "tCountry"



Seems to work fine.

Thanks for your post, it was most helpfuly!

Andy.
Was This Post Helpful? 0
  • +
  • -

#6 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 125
  • Posts: 704
  • Joined: 28-April 07

Re: Multiple Combo Boxes

Posted 30 April 2010 - 01:54 PM

you're welcome :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1