VB.net combobox valuemember question

Posted on 2012-09-13
Medium Priority
Last Modified: 2012-09-16
Hi Experts,
I'm struggling with the valuemember within a combo box within a windows vb.net application

I've populated my combobox using
        cboControl.DataSource = m
            cboControl.DisplayMember = "name"
            cboControl.ValueMember = "id"

data looks like
id    Name
1     Mark
5     Fred
8     Claire
55   Vikki

etc etc....

which all works fine and it displays the name in the combobox as expected

However what i want to do is set the displaymember from somewhere else in my application however i don't have the "Name" all i have is the "ID"

I understand i can get the valuemember by using "cboControl.SelectedValue.ToString"

So my question is is how would i select say the name "Vikki" when all i have is the "ID" of 55?

thanks in advance
Question by:potnoodle13

Accepted Solution

effes earned 2000 total points
ID: 38396270
Just assign the ID to SelectedValue like this:
cboControl.SelectedValue = 55

Open in new window

The combobox will automatically display the corresponding name from your datasource.

Author Closing Comment

ID: 38403575

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question