Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# ComboBox Text & Values

Posted on 2009-05-08
6
Medium Priority
?
527 Views
Last Modified: 2012-05-06
Using the Items collection for a combobox how do I assign Text and Values to it via the editor (or via the designer code for that matter).

eg:

this.products.Items.Add("BW");

BW is the value
where the text would be be: Black&White

I would like to manually add these values as there is not enough to create a collection etc.
0
Comment
Question by:directxBOB
  • 3
  • 2
6 Comments
 
LVL 16

Assisted Solution

by:CuteBug
CuteBug earned 1200 total points
ID: 24334818
When you add the combo box via the designer, you will see a small black triangle on the top right corner of the combo box.
Click on that.
Click on "Edit Items".
Now add your items (one item per line)
0
 
LVL 1

Accepted Solution

by:
Acumentality earned 800 total points
ID: 24335019

this.products.Items.Add("BW");
this.products.selectedIndex = this.products.Items.Count-1;
this.products.selectedValue = "Black&White";

Open in new window

0
 

Author Comment

by:directxBOB
ID: 24335035
Great, and out of interest how do I do this in the Designer Code just so I know how to do it for future reference.

Cheers
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 16

Assisted Solution

by:CuteBug
CuteBug earned 1200 total points
ID: 24335215
If you add it via the Designer, it will automatically add the required code in the Designer code.
You need not edit the Designer code directly.
0
 

Author Comment

by:directxBOB
ID: 24335595
Ok, but for my own knowledge (and given that I can't get edit items up on this control) how do I do this via code?
0
 

Author Comment

by:directxBOB
ID: 24362063
Any ideas how to do this via Code?
0

Featured Post

Independent Software Vendors: 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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

783 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