Default item for DropDownList

  • Thread starter Thread starter Brian Henry
  • Start date Start date
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
 
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 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.
 
Back
Top