Solved

Selecting a value in a combobox

Posted on 2008-10-04
2
959 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:charlesbaldo
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:charlesbaldo
ID: 31503133
Wow too easy, I think I am going to like doing winforms instead of webapps
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now