Solved

Selecting a value in a combobox

Posted on 2008-10-04
2
986 Views
Last Modified: 2013-12-17
Hi I am new to c# winforms and came from the webapps world.

I have a combo box that has a collection value in it
County
State
Town
Private

I am reading the owner form the database and want to set the value to what it is in the database (will always be one of the collection values or null)

In the asp.net c# world I used
findValue = reader["Owner"].ToString();

ddOwner.SelectedValue = ddOwner.SelectedIndex = ddOwner.Items.IndexOf(ddOwner.Items.FindByValue(findValue));

But in the winforms world I am getting an Error because Items has no FindByValue method defined.

How can I set the comboBox to the value i retrieved form the database?

Thanks
0
Comment
Question by:Charles Baldo
[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 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22643360
this should work
ddOwner.SelectedValue = findValue;
0
 

Author Closing Comment

by:Charles Baldo
ID: 31503133
Wow too easy, I think I am going to like doing winforms instead of webapps
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
aspx ascx, c# 7 44
vb.net application has warrnings about VB6 calls. 2 48
Removing Version of .NET in Windows 10 17 130
.NET universe documentation poster 2 25
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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