How to clear combo box contents in vb.net

If for textbox it is textbox1.clear, etc. What is the equivalent for combobox to clear the value.

5 Answers

Try using combobox.Items.Clear()

3

If your combobox is set with the DropDownList, then use Combobox1.SelectedIndex = -1

To clear the items that are in the drop down menu combobox.SelectedIndex = -1 will work. To clear what the user types in the combobox combobox.Text = String.Empty will work because the combobox also has a text property. Use both of these to ensure it will clear the fields.

first null the the datasourcecombobox.DataSource = Nothingthen clear the combobox combobox.Items.Clear()

When I need to clear a combo box, I use

combobox1.text=""

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like