Solved

windows forms filling combobox's

Posted on 2004-09-11
2
219 Views
Last Modified: 2010-04-23
I am trying to populate a combobox with a value and text.
i know how to do it in asp but how do you do it on windows forms?

this is what i have so far

 For index = 0 To length - 1 Step 1

            cboProvider.Items.Add(providerData.Rows(index).Item(0))
        Next

what i actually want is  in my combobox my value would be 123 but it would display john
0
Comment
Question by:genesisproject
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Expert Comment

by:drichards
ID: 12035595
The Windows.Forms.ComboBox uses objects in its Items collection.  The ToString() method of the item is what gets diaplayed and the object itself is the item.  Here's a previous answer to this question that gives a code example:

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21107318.html
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 250 total points
ID: 12035629
Hi there,
if you are using data set or table, bind the two columns to the combo box.
Use DisplayMember and value member property.

cboProvider.DisplayMember = "NameField"
cboProvider.ValueMember = "IDField"

Example: http://www.thescarms.com/dotNet/BindCombobox.asp
-Baan
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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