Treeview and Right Click

dennisvb

Member
Joined
Nov 19, 2009
Messages
10
Programming Experience
10+
I have been working with VB 6.0 for years . I am converting an app that uses treeviews to VB.Net 2008. The way it use to work the tree grid started with a list of the drives on the system. Left click drilled down in the selected drive or directory. Right click would perform an action with the selected drive or directory.

In VB.Net it appears you can only select with left click using the AFTERSELECT event.

Is there a way to select a node with right click?
 
I found the answer:

VB.NET:
Expand Collapse Copy
    Private Sub treeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If (e.Button = MouseButtons.Right) Then
            treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y)
        End If
    End Sub
 
Last edited by a moderator:
Back
Top