Default item for DropDownList

B

Brian Henry

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
 
Q

Qwert

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
 
H

Herfried K. Wagner [MVP]

Brian Henry said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top