CodeItBetter Programming Another VB Programming Blog

How to add PopUp Menu to TreeView

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'Controls - How to add PopUp Menu to TreeView

Option Explicit
 
'Add a TreeView to your form. Add few nodes to the treeview.
'Add a Menu (Named MyMenu) and few Sub Menus.
'When you right click the menu will popup.

Private Sub TreeView1_Mousedown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim nod As Node
    If Button = vbRightButton Then
        Set nod = TreeView1.HitTest(x, y)
        On Error GoTo EmptyNode
        nod.Selected = True
        On Error GoTo 0
        Me.PopupMenu MyMenu
EmptyNode:
        On Error GoTo 0
    End If
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.