Plucka
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SpeedCombo.SelectedIndex = 0
works but you got me on the right track.
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.Cou nt - 1)
If objDropDownList.Items(intC ount).Valu e = myVarToCheckAgainstThen
objDropDownList.Items(intC ount).Sele cted = True
Exit For
End If
Next intCount
Hope this helps
James :-)
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.Cou
If objDropDownList.Items(intC
objDropDownList.Items(intC
Exit For
End If
Next intCount
Hope this helps
James :-)
Sorry about being a little late on the better response ..... :-(
James :-)
James :-)
ASKER