I have a TreeView and a Context Menu. I want to show the Context Menu ONLY when I right click on the ROOT node and not the child nodes.
This is what I have so far. This shows the Context Menu even when I right click on the child nodes. How can I change this so that the Menu shows only when I right click on the root node? Is it possible?
if(e.Button == MouseButtons.Right)
{
// Select the clicked node
treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y);
if(treeView1.SelectedNode != null)
{
myContextMenuStrip.Show(treeView1, e.Location)
}
}