Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Question - VB.Net

Status
Not open for further replies.

ProjectExplorer

Programmer
Mar 22, 2002
95
GB
I want to load a Combo Box with a simple list of Countries from a table using the add method.

When I load the Countries I also need to add the Countries unique table ID so I can retrieve the users selection by the ID not the Country Name.

i.e if "Germany" had an unique table ID of "17", I need to be able to get "17" as the selection.

How do I load the combo box with both values so I can retrieve the Conutry ID rather than than the Country Name.

I have been used to doing this with Access VBA but cant see how it's done with VB.net. (I'm obviously buying the wrong books!)

Many thanks.
 
Hi ProjectExplorer,

Where you able to make the table?

If you have the table created then you can do this to fill your combobox
Code:
With ComboBox1
    .Datasource = <table>
    .DisplayMember = <CountryName Tablefield>
    .ValueMember = <CountryID tableField>
End With

You can retrieve the id of the country with this code
Code:
Combobox1.SelectedValue

Greetings,
Ernst Jan
 
Many thanks Ernst Jan,

I will give this a go....seems to be just what I needed.

Thanks for your help.

 
This thread from a similar question i had may help, too:

thread796-1490847


"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top