Results 1 to 4 of 4

Thread: Which Mouse button

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    Which Mouse button

    I haev a picture, and I'm currently coding in the picturebox_Clicked method. How can I differentiate between which mouse button is being clicked here and do different tasks..
    Ex.
    Right button -- msgbox "right"
    left button -- msgbox "left"

  2. #2
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: Which Mouse button

    well, you could use a context menu for right clicks. other than that i dont know.

  3. #3
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Which Mouse button

    Quote Originally Posted by JohnRChick
    I haev a picture, and I'm currently coding in the picturebox_Clicked method. How can I differentiate between which mouse button is being clicked here and do different tasks..
    Ex.
    Right button -- msgbox "right"
    left button -- msgbox "left"
    Hi,

    You could try this;

    VB Code:
    1. Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
    2.         If e.Button = MouseButtons.Left Then
    3.             TextBox1.Text = "Button Left" & Space(1) + CStr(e.X) + "," + CStr(e.Y)
    4.         End If
    5.         If e.Button = MouseButtons.Right Then
    6.             TextBox1.Text = "Button Right" & Space(1) + CStr(e.X) + "," + CStr(e.Y)
    7.         End If
    8.     End Sub

    I couldn't find anything more.

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  4. #4
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    Re: Which Mouse button

    Don't use the PictureBox click event use the MouseDown event instead.

    VB Code:
    1. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
    2.         'get the button that was pressed
    3.         'just show it in a label......
    4.         lblMouse.Text = e.Button.ToString
    5.     End Sub

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