yukisu
asked on
How to set ComboBox that has DropDownList style to empty after the Form is displayed for the first time?
i tried using ComboBox1.SelectedIndex = -1 in the Form Load Events but it did not work, the ComboBox1 still displaying Index 0
thanks
thanks
If you just want to have the combobox text area emtpy change too dropdown and not dropdownlist
If you want to clear the whole list then
ComboBox1.Items.Clear()
ComboBox1.Items.Clear()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Text = Nothing
ComboBox1.SelectedItem = Nothing
End Sub
ASKER
planocz,
ComboBox1.Items.Clear() does not work in Form_Load
UnFiRe,
ComboBox1.Text = Nothing
ComboBox1.SelectedItem = Nothing
also do not set the dropdownlist to empty
i want to set the dropdownlist to empty so the user is force to select one value from the list, thus the default value for the dropdownlist must be blank.
i can do this by setting ComboBox1.SelectedIndex = -1, but only after i called it when the form already loaded.
setting ComboBox1.SelectedIndex = -1 in the form_load event does not work
so when the form open for the first time, the dropdownlist index always go back to index 0
anyone know how to set the dropdownlist index to -1 (empty/blank value) on Form_Load Event?
thanks
ComboBox1.Items.Clear() does not work in Form_Load
UnFiRe,
ComboBox1.Text = Nothing
ComboBox1.SelectedItem = Nothing
also do not set the dropdownlist to empty
i want to set the dropdownlist to empty so the user is force to select one value from the list, thus the default value for the dropdownlist must be blank.
i can do this by setting ComboBox1.SelectedIndex = -1, but only after i called it when the form already loaded.
setting ComboBox1.SelectedIndex = -1 in the form_load event does not work
so when the form open for the first time, the dropdownlist index always go back to index 0
anyone know how to set the dropdownlist index to -1 (empty/blank value) on Form_Load Event?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
UnFiRe,
nice solution, but i cannot set the text for the ComboBox since it is a DropDownList
thanks a lot
nice solution, but i cannot set the text for the ComboBox since it is a DropDownList
thanks a lot