I'm still working on my selection form..
Which has got a listbox. When nothing is selected the selectedindex = -1.
Now when i select something i can't deselect it anymore..
So I made up this deselect button with the following click-event:
myListbox.selectedIndex = -1
But this produces an [runtime] error everytime.
Does anybody have a suggestion?
if I want to give the user the chance to deselect a listbox entry I'll do the following:
I add a "dummy"-entry at the first (or last) position of the listbox named "<no selection>" (or something like that) and pre-select this entry before showing the listbox.
Now you can proof during runtime, if the first (or last) entry is selected, which means, nothing is selected ...
Thanks for all the replies.
For the time being I will just refill my listbox. Which does the same trick as well. But it might become too slow when my list becomes longer and longer..
I hope in the future the functionality to deselect-all will be implemented..
Thanks!
Ghislain started off setting the index to -1 but, as mentioned, that gives a runtime error. If you trap that error with an empty error handler you'll get the deselection without the error being reported.
Sub EventsList_LostFocus
ErrorLabel(ErrHandler)
EventsList.SelectedIndex = -1
return
ErrHandler:
End Sub
If your deselection comes within other code you'll need to have a goto to just after the selectedindex = -1 code.