N
Nadav
Hello.
I have a combobox in a form (cmbNames).
The DataSource property is some arraylist of strings.
I have a button which is supposed to "clean" the combobox and deselect any
item.
Therefore, I do:
cmbNames.SelectedIndex = -1;
If index 0 was selected (meaning, the first item on the list) - the combobox
indeed goes to index -1 and there is no selected item.
if the selected item is not 0, meaning not the first item in the list - the
1st click on the button will select item 0 (the SelectedItem will be 0), and
another click will select nothing.
Why does that happen ?
(I attached a messagebox to the IndexChanged event of the combo, that pops
up the current index. When let's say index 3 is selected, on the click of
the button 2 messageboxes appear, the first saying -1, the second says 0. I
donno why is that!)
10x
I have a combobox in a form (cmbNames).
The DataSource property is some arraylist of strings.
I have a button which is supposed to "clean" the combobox and deselect any
item.
Therefore, I do:
cmbNames.SelectedIndex = -1;
If index 0 was selected (meaning, the first item on the list) - the combobox
indeed goes to index -1 and there is no selected item.
if the selected item is not 0, meaning not the first item in the list - the
1st click on the button will select item 0 (the SelectedItem will be 0), and
another click will select nothing.
Why does that happen ?
(I attached a messagebox to the IndexChanged event of the combo, that pops
up the current index. When let's say index 3 is selected, on the click of
the button 2 messageboxes appear, the first saying -1, the second says 0. I
donno why is that!)
10x