We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Context menu of a tree node

Hi, How can i add context menu to a tree node Syncfusion tree has a context menu property for the whole tree component what if i need only for a particular node Shri

1 Reply

AD Administrator Syncfusion Team August 15, 2004 09:33 PM UTC

Hi Shri, Yes, it is possible to display a custom context-menu depending on which node the context-menu was invoked. Please handle the TreeViewAdv''s MouseDown event as shown below for this purpose : private void treeViewAdv1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { // Get the node on which the context-menu was invoked Point p = this.treeViewAdv1.PointToClient(Control.MousePosition); TreeNodeAdv node = this.treeViewAdv1.PointToNode(p); // Set custom BarItems for each node BarItem bitem = new BarItem(); bitem.Text = "This is " + node.Text; // Clear the previous node''s BarItems this.parentBarItem1.Items.Clear(); // Add new node''s BarItems this.parentBarItem1.Items.Add(bitem); } } The complete sample illustrating this is attached here. Please refer to it and let me know if this meets your requirements. Thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Loader.
Up arrow icon