CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2008
    Posts
    2

    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

  2. #2
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: Problem with Mouse events

    Try using the Click And DBlClick events, rather than MouseClick and MouseDblClick.
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  3. #3
    Join Date
    Aug 2008
    Posts
    2

    Unhappy Re: Problem with Mouse events

    yeah I tried but no use same response..

  4. #4
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    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?
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    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...

  6. #6
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    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.

  7. #7
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    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.
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  8. #8
    Join Date
    Jun 2008
    Posts
    29

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured