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 Sub
Mine 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!!!!!!!!!!!