?
Solved

trouble setting a drop down item

Posted on 2008-02-06
6
Medium Priority
?
151 Views
Last Modified: 2013-12-17
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
0
Comment
Question by:newbieweb
  • 3
  • 3
6 Comments
 

Author Comment

by:newbieweb
ID: 20837286
I meants to say I had it set to a DropDownList for DrtopDownStyle

newbieweb
0
 
LVL 11

Expert Comment

by:vs1784
ID: 20837297
Try this

DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(<value>));
0
 

Author Comment

by:newbieweb
ID: 20837322
FindByValue does not appear in the Items object.

I use C# 2.0.

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 11

Expert Comment

by:vs1784
ID: 20837358
Strange!! i use C# 2.0 and i have FindByValue as Member in Items

Which type of server web control is it?
0
 

Author Comment

by:newbieweb
ID: 20837366
it's a win forms application.
0
 
LVL 11

Accepted Solution

by:
vs1784 earned 2000 total points
ID: 20837386
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
Suggested Courses
Course of the Month5 days, 12 hours left to enroll

588 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