First double-click lost?

J

Josh Sale

I have an Excel application that includes a form with a couple of listboxes
and command buttons. For one of the listboxes I want to capture both
single-click and double-click events. So I have a bit of code like:

Private Sub lstMemberList_Change()
...
End Sub


Private Sub lstMemberList_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
...
End Sub ' lstMemberList_DblClick

If I launch the form, single-click an item and then double-click the same
item everything works OK.

If I launch the form, single-click an item and then double-click some other
item everything works OK.

However, if I launch the form and then immediately double-click an item I
get the Change event but never get the DblClick event. A subsequent
double-click in this same launch of the form works OK.

So it appears that the first double-click on the listbox after the form is
launched is lost. I tried recoding the Change event to a Click event and
that didn't make any difference. I've tested this in XL97 and 2003 with the
same results.

Any thoughts?

TIA,

josh
 
G

Guest

The problem seems to be that nothing in the listbox is selected until you
click on it; so the first click actually causes the Change event to occur
(you are changing from "Nothing" to the selected value). The only way I have
found around this is to set the listbox value by code first, e.g:
ListBox1.ListItem = 0. If this is on a userform you can set this when the
userform is activated, then the first click does not fire the Change event.
 
J

Josh Sale

Actually when the listbox is populated with members, one of them is always
initially selected. ListItem is never = -1.

Any other ideas?

josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top