Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Selections of a Combobox

I have a combobox with values that when selected, lead to other questions.

I have a button that I want to be an "Up one level" button that clears all the following questions. It should reset the display of of the combobox to nothing, like before any options were selected, so the user can make a selection.

I tried setting the Value = 0, the ListIndex = -1.

I don't want to use "Clear" because I want to preserve the values in the combobox.

I looked through the properties of a combobox and I can't pick out which one will do what I want.

like image 491
Paul Avatar asked Oct 02 '12 20:10

Paul


People also ask

How do I remove items from combobox?

To remove an itemCall the Remove or RemoveAt method to delete items. Remove has one argument that specifies the item to remove. RemoveAt removes the item with the specified index number.

How do you clear a combobox in Visual Basic?

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.

How do you clear a combobox in Python?

You can create a combobox widget by initializing the constructor of Combobox(root, width, text) widget. Consider the case, if the user wants to clear the selected value from the combobox widget, the only way you can do so is to set the value of the combobox widget as NULL by using the set (' ') method.


2 Answers

If you use: ComboBox1.ListIndex = -1 with no list items then there will be no effect. This is a problem if you're dynamically loading the items. Use: ComboBox1.Value = Null to clear the value as mentioned above.

like image 109
sybb Avatar answered Sep 18 '22 19:09

sybb


Listbox.Value=null

should do the trick.

like image 28
Johanness Avatar answered Sep 19 '22 19:09

Johanness