Problem with Mouse events
Hi friends,
I had a problem while handling mouse events.
I am using a listview control of vb2005.
My requirement is to have different results when the listview item is clicked and when it doubleclicked..
i am using listview_mouseclick and listview_mousedoubleclick events..
but when i tried to doubleclick the mouse for the first click itself the listview_mouseclick event is raising...
Please help me out to over come this situation and handle the events correctly
Re: Problem with Mouse events
Try using the Click And DBlClick events, rather than MouseClick and MouseDblClick.
Re: Problem with Mouse events
yeah I tried but no use same response..
Re: Problem with Mouse events
It makes sense, I suppose.
What exactly are you doing in the events? Considering that a DblClick seems to require a click in the same place, could you undo whatever action the click performs in the DblClick event?
Re: Problem with Mouse events
I'd suggest using only the click event. In there you could test if the Right button was pressed or the Left button. Then, you work with left & right clicks.
Just a dumb idea...
Re: Problem with Mouse events
Quote:
Originally Posted by HanneSThEGreaT
I'd suggest using only the click event. In there you could test if the Right button was pressed or the Left button. Then, you work with left & right clicks.
Just a dumb idea...
Not a dumb Idea at all. It fits the bill for this solution perfectly.
I would take it even further. Add a popup menu. That way, if you later find you need a third option, it would be easy to add in. Most people do very well with popups. And it might not be as intuitive as using right and left clicks.
Re: Problem with Mouse events
Of course, you can vary that slightly and go for the (possibly) more common option of (remembering this is in a ListView):
LeftClick = Select (Default in ListView)
RightClick = Select, Pop-Up Menu
DblClick = Select, Perform Default Action on item.
Re: Problem with Mouse events
You could also declare a timer as a public variable and record the time every time the click event is fired.
If the timespan is too short, you exit the mouseclick procedure.