My Contextual menu appears no matter where in the treeview i RMB
help
attached image shows my treeview i only want it to appear on "Default" "Roll1" "Roll2" and Roll3"
Madaxe![]()
Code:Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown ' Show menu only if Right Mouse button is clicked If e.Button = MouseButtons.Right Then ' Point where mouse is clicked Dim p As Point = New Point(e.X, e.Y) ' Go to the node that the user clicked Dim node As TreeNode = TreeView1.GetNodeAt(p) TreeView1.SelectedNode = node If node Is Nothing Then Exit Sub If node.Text Is "Default" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll1" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll2" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll3" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll4" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll5" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll6" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll7" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll8" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll9" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) ElseIf node.Text Is "Roll10" Then ContextMenuStrip1.Show(TreeView1, New Point(e.X, e.Y)) End If End If End Sub




Reply With Quote