[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

windows forms filling combobox's

Posted on 2004-09-11
2
Medium Priority
?
226 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 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

650 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