Home Forums WinForms controls Other WinForms controls How to catch event MouseRightClick on Xceed TreeView Reply To: How to catch event MouseRightClick on Xceed TreeView

User (Old forums)
Member
Post count: 23064

You’ll need to wire up the TreeView’s MouseUp event, trap for the correct MouseButton press, then use the TreeView’s GetItemAtPoint method to find your selected Node.


treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(treeView_MouseUp);

private void treeView_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
// test for right mouse button click
if (e.Button == MouseButtons.Right)
{
Point pt = new Point(e.X, e.Y); // click coordinates
Node selectedNode = treeView.GetItemAtPoint(pt) as Node;

}
}

Hope this helps!

Imported from legacy forums. Posted by Christopher (had 3124 views)