Hi - I've seen quite a few posts that almost match this but haven't
found a solution that works.
I have an explorer-like application with a treeview in the lefthand
pane. When I right-click on a node, a context menu appears. How can I
get different context menus to appear depending on which node is
chosen. Here's my existing code:
Private Sub treeView1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
If e.Button = MouseButtons.Right Then
TreeView1.SelectedNode = TreeView1.GetNodeAt(e.X, e.Y)
Dim ClickPoint As Point = New Point(e.X, e.Y)
Dim ClickNode As TreeNode =
TreeView1.GetNodeAt(ClickPoint)
If ClickNode Is Nothing Then
Return
End If
' Show context menu
ContextMenu1.MenuItems.Clear()
ContextMenu1.MenuItems.Add("Add " &
TreeView1.SelectedNode.Text, New EventHandler(AddressOf
menuItemAdd_Click))
ContextMenu1.MenuItems.Add("Delete " &
TreeView1.SelectedNode.Text, New EventHandler(AddressOf
menuItemDelete_Click))
ContextMenu1.Show(TreeView1, clickpoint)
End If