Home » Controls » How to add PopUp Menu to TreeView
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 |
Enjoy this article?
Filed under: Controls
Leave a comment