Results 1 to 5 of 5

Thread: [RESOLVED] Mouse right click??

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Resolved [RESOLVED] Mouse right click??

    Hey I was wondering what the event is when the right mouse button is clicked.
    Is this event included in mouseclick? If so do i have to make an if statement asking which mouse button has been pressed??

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Mouse right click??

    Use the MouseClick event and check to see which mouse button was clicked by using e.Button, something like
    VB Code:
    1. If e.Button = Windows.Forms.MouseButtons.Right Then
    2.  
    3. End If

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    10

    Re: Mouse right click??

    Could you use that in an example it seems to create errors with my handle and e.button appears undefined.

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Mouse right click??

    It's the "MouseClick" event of the control, not the "Click" event...

    VB Code:
    1. Private Sub Form1_MouseClick(ByVal sender As Object, _
    2.                                  ByVal e As System.Windows.Forms.MouseEventArgs) _
    3.                                  Handles Me.MouseClick
    4.         If e.Button = Windows.Forms.MouseButtons.Right Then
    5.             MsgBox("Right click detected")
    6.         End If
    7.     End Sub

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Mouse right click??

    The MouseClick event is new in .NET 2.0. If you're using .NET 1.x (please specify in future) you have to handle the MouseDown event instead.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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