468,140 Members | 1,469 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

Default item for DropDownList

is there anyway to set the default selected item for a combobox's
dropdownlist? I have items in the items collection, but at runtime nothing
is selected by default, I'd like to have an item selected when the form
shows instead of nothing. thanks
Nov 21 '05 #1
2 1322
In the load event of the form that has the combobox control, select the
requested value.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
....
If Me.ComboboxName.Items.Count > 0 Then
Me.ComboboxName.SelectedIndex = 0
End If
....
End Sub

"Brian Henry" <no****@nospam.com> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl...
is there anyway to set the default selected item for a combobox's
dropdownlist? I have items in the items collection, but at runtime nothing
is selected by default, I'd like to have an item selected when the form
shows instead of nothing. thanks

Nov 21 '05 #2
"Brian Henry" <no****@nospam.com> schrieb:
is there anyway to set the default selected item for a combobox's
dropdownlist? I have items in the items collection, but at runtime nothing
is selected by default, I'd like to have an item selected when the form
shows instead of nothing.


Set the 'SelectedIndex' property to the index of the item you want to be the
selected item.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Aymer | last post: by
5 posts views Thread by Kris Rockwell | last post: by
2 posts views Thread by huzz | last post: by
4 posts views Thread by rn5a | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.