Solved

Selecting a value in a combobox

Posted on 2008-10-04
2
950 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C# Export DataGridView 4 39
Data Saving(2) 2 26
Hide Tab Page 3 19
Trouble connecting to SqlServer database 4 32
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

19 Experts available now in Live!

Get 1:1 Help Now