Solved

Default Value Drop Down List

Posted on 2004-03-25
5
478 Views
Last Modified: 2012-05-04
Hi,

I have a combo setup as a drop down list, defined the values for the list in the collection, how through the properties do I set the first value to be selected.
0
Comment
Question by:Plucka
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
culshaja earned 250 total points
ID: 10675553
You need to loop through the items and set the slected property iof the item that you want to be selected be set to true.

James :-)
0
 
LVL 18

Author Comment

by:Plucka
ID: 10675565
Right, if i knew how to do that i'd be half way there :(
0
 
LVL 18

Author Comment

by:Plucka
ID: 10675604
SpeedCombo.SelectedIndex = 0

works but you got me on the right track.
0
 
LVL 7

Expert Comment

by:culshaja
ID: 10675647
Are you using WinForms or ASP.Net?

In Winforms you just use the slectedIndex property i.e.

cboX.SelectedIndex = 2

If you need to loop through it you use the following

        Dim c As Integer
        For c = 1 To cboX.Items.Count - 1
            If CType(cboX.Items(c), String) = myStringVarToCheckAgainst Then
                cboX.SelectedIndex = c
                Exit For
            End If
        Next

In ASP.Net you use the following code:

For intCount = 0 To (objDropDownList.Items.Count - 1)
    If objDropDownList.Items(intCount).Value = myVarToCheckAgainstThen
        objDropDownList.Items(intCount).Selected = True
        Exit For
    End If
Next intCount

Hope this helps

James :-)
0
 
LVL 7

Expert Comment

by:culshaja
ID: 10675657
Sorry about being a little late on the better response .....  :-(

James  :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This video discusses moving either the default database or any database to a new volume.
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: …

707 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

17 Experts available now in Live!

Get 1:1 Help Now