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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add data to a combo box/listbox

Status
Not open for further replies.

testeng

Technical User
Apr 5, 2001
32
US
Hi I am new to .net and having a hard time switching from VB6.
I have a list of employess and there ID that I would like to put into a combo box and display there name but when selected only pick there ID. In VB6 the code was .additem for the employee name and .itemdata(x) for the ID. How does the .net do this same thing?
 
if you are using a dataset, it is this:

combobox.DataSource = datasetname.Tables("tablename")
combobox.DisplayMember = "empl_name"
combobox.ValueMember = "empl_ID"

you can then use combobox.selectedvalue to get the id, but the user only sees the empl_name (employee name).

does that help you?


hayt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top