Link to home
Start Free TrialLog in
Avatar of Plucka
PluckaFlag for Australia

asked on

Default Value Drop Down List

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.
ASKER CERTIFIED SOLUTION
Avatar of culshaja
culshaja
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Plucka

ASKER

Right, if i knew how to do that i'd be half way there :(
Avatar of Plucka

ASKER

SpeedCombo.SelectedIndex = 0

works but you got me on the right track.
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 :-)
Sorry about being a little late on the better response .....  :-(

James  :-)