Results 1 to 4 of 4

Thread: .NET TreeView and Mouse Clicks

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    104

    .NET TreeView and Mouse Clicks

    In the TreeView's MouseUp event, how do I detect whether the user clicked the right or left mouse button?

    I know that you can get whether the mouse did something by checking the action property on the TreeViewEventArgs object but I can't find anything on which button the user clicked on the mouse.

    Thanks.
    Last edited by ttingen; Jun 3rd, 2002 at 11:57 AM.
    Um americano que fala portugues.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Code:
    Private Sub TreeView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseUp 
            Dim mySelectedNode As TreeNode 
            mySelectedNode = TreeView1.GetNodeAt(e.X, e.Y) 
            If e.Button = MouseButtons.Right Then 
                'do stuff 
            ElseIf e.Button = MouseButtons.Left Then 
                'do stuff 
            ElseIf e.Button = MouseButtons.Middle Then 
                'do stuff etc 
            End If 
        End Sub
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    that was quick.

    I thought the event was restricted to the TreeViewEventArgs object but I guess event handlers just have to have an object that's derived from EventArgs.

    thanks again.
    Um americano que fala portugues.

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    I think itdepends on the Event..such as with MouseUp, I believe you can use EventArgs, MouseEsventArg, or the TreeViewEventArgs
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

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