I have a treeview with two nodes..I m showing the contextmenu when the user clicks on any portion of treeview ....
Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim N As New TreeNode() Me.TreeViewCategories.Nodes.Clear() With Me.TreeViewCategories.Nodes N = .Add("", "Main", 0) N.Nodes.Add("", "First Child", 0) N.Nodes.Add("", "Second Child", 0) End With TreeViewCategories.ExpandAll() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub TreeViewCategories_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeViewCategories.MouseDown If e.Button = Windows.Forms.MouseButtons.Right Then ContextMnuTreeview.Show(TreeViewCategories, e.X, e.Y) End If End SubMine probs is that when i right click on Second Child,Contextmenu is showing....But aotomatically root is selected....Y....?Plz copy this code,U will get to know what i want to ask!!!!!!!!!!!
Add Following code
TreeView1.Nodes.Add("Root")
TreeView1.Nodes(0).Nodes.Add("Work")
TreeView1.Nodes(0).Nodes.Add("Play")
TreeView1.Nodes(0).Nodes(0).ContextMenuStrip = ContextMenuStrip1 __avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241