troubleshooting Question

How do I access another column of data in a ComboBox?

Avatar of Agent909
Agent909 asked on
.NET ProgrammingVisual Basic.NETMicrosoft Development
12 Comments1 Solution250 ViewsLast Modified:
Merry Christmas, experts.  I hope someone is out there.

Here's my situation:
I have a Codes table with two fields, "Code" and "Description".  I have successfully added the codes to the ComboBox, cboDocType, and want to access the "Description" column when the user selects a code in the combobox.  The "Description" needs to go into a label control, "labCode", so that the user will know that they selected the correct code.  What code do I need to accomplish this?  Here's my code so far:

Dim dsCodes As New DataSet
Dim codesAdapter As New SqlDataAdapter("SELECT * FROM Codes ORDER BY Code", myConnection)
codesAdapter.Fill(dsCodes, "Codes")
cboDocType.DataSource = dsCodes.Tables("Codes")
cboDocType.DisplayMember = "Code"
cboDocType.ValueMember = "Code"
labCode.Text = "I want to display the Codes.Description here."

Thank you.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros