Click here to Skip to main content
15,908,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello i have a treeview that contains many nodes.
I want onclik on any node a menu pops up.
I did the event on click and the menu shows but always on top-left not on the selected node.

What I have tried:

<pre lang="c#">radMenuImporter.Click += new EventHandler(MenuItem_Importer_Click);
            radMenuAfficher.Click += new EventHandler(MenuItem_Afficher_Click);
            radMenuEditer.Click += new EventHandler(MenuItem_Editer_Click);
Posted
Updated 21-Oct-20 8:54am

@User-14814377 : If you paid for the expensive Telerik software, use their support system and documentation. Find out if their RadTreeView offers the WinForm Events shown here.

with WinForms, I frequently use code like this with a TreeView:
C#
private TreeNode currentClkNode, currentDblClkNode;

private void treeView1_MouseDown(object sender, MouseEventArgs e)
{
    if(treeView1.GetNodeAt(e.Location) == null)
    {
        // handle mouseclick on TreeView client area
        // that is not a click on a Node
    }
}

// thiis will be called on a Node DoubleCliick
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
    currentClkNode = e.Node;
    currentDblClkNode = null;
}

private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
    currentDblClkNode = e.Node;
}
 
Share this answer
 
v2
The TreeView doesn't have a click event for nodes, it just has one for the whole TreeView.
Instead, use the TreeView.AfterSelect Event (System.Windows.Forms) | Microsoft Docs[^] which is what it is there for!
 
Share this answer
 
Comments
BillWoodruff 21-Oct-20 14:50pm    
OP appears to be using Telerik RadTreeView !

WinForm TreeView has NodemouseClick ... see below ... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900