How do I set a VB.Net ComboBox default value

OR

you can write this down in your program

Private Sub ComboBoxExp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load
    AlarmHourSelect.Text = "YOUR DEFAULT VALUE"
    AlarmMinuteSelect.Text = "YOUR DEFAULT VALUE"
End Sub

so when you start your program, the first thing it would do is set it on your assigned default value and later you can easily select your required option from the drop down list. also keeping the DropDownStyle to DropDownList would make it look more cooler.

-Starkternate


Just go to the combo box properties - DropDownStyle and change it to "DropDownList"

This will make visible the first item.


 ' Your code filling the combobox '
 ...

 If myComboBox.Items.Count > 0 Then
     myComboBox.SelectedIndex = 0    ' The first item has index 0 '
 End If

Tags:

Vb.Net