Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Selecting a value in a combobox

Posted on 2008-10-04
2
Medium Priority
?
999 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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 article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

661 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