Click to See Complete Forum and Search --> : Problem with Mouse events
cvsschaitu
August 25th, 2008, 06:24 AM
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
javajawa
August 25th, 2008, 06:26 AM
Try using the Click And DBlClick events, rather than MouseClick and MouseDblClick.
cvsschaitu
August 25th, 2008, 07:27 AM
yeah I tried but no use same response..
javajawa
August 25th, 2008, 07:33 AM
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?
HanneSThEGreaT
August 25th, 2008, 08:19 AM
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...
sotoasty
August 25th, 2008, 09:00 AM
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.
javajawa
August 25th, 2008, 09:06 AM
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.
adambom
August 26th, 2008, 02:49 PM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.