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.
Unfortunately, activation email could not send to your email. Please try again.

Context menu of a tree node

Thread ID:





17735 Aug 15,2004 01:01 PM Aug 15,2004 05:33 PM Windows Forms 1
Tags: Tools
Asked On August 15, 2004 01:01 PM

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

Administrator [Syncfusion]
Replied On August 15, 2004 05:33 PM

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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.