trouble setting a drop down item

I have a combox box I set to have a simple drop down style.   And I popukated a list, 1 through 10 item, named "1" through "10".

I'd like to set it to display 2, and can not sem to do it.  I tried these:

maxRunSizeCombo.SelectedItemIndex = 1;

and

maxRunSizeCombo.SelectedItem = (object)2;

but neither works.

Could someone tell me how do do this easy task??

thanks,
newbieweb
newbiewebSr. Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

newbiewebSr. Software EngineerAuthor Commented:
I meants to say I had it set to a DropDownList for DrtopDownStyle

newbieweb
0
vs1784Commented:
Try this

DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(<value>));
0
newbiewebSr. Software EngineerAuthor Commented:
FindByValue does not appear in the Items object.

I use C# 2.0.

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

vs1784Commented:
Strange!! i use C# 2.0 and i have FindByValue as Member in Items

Which type of server web control is it?
0
newbiewebSr. Software EngineerAuthor Commented:
it's a win forms application.
0
vs1784Commented:
Oops.
Ok i hope you are using combobox

you can set selected index using

combobox1.SelectedIndex = 3;

If it does not work then i suspect that any of the below event is fired again to reset the selectedindex

SelectedValueChanged
SelectedindexChanged
SelectionChangeCommitted

If you have implemented any of this, put a break point and check what is happening.

Hope it helps.

Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.