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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Customizing the context menu

Thread ID:





42797 Apr 6,2006 05:15 AM UTC Apr 6,2006 09:09 AM UTC WinForms 2
Tags: Tools
Administrator [Syncfusion]
Asked On April 6, 2006 05:15 AM UTC

Hi I am using treeViewAdv. I need to customize the context menu to display the name of the selected node when right clicked on it. Thanks in Advance, Nik

Deepa TS [Syncfusion]
Replied On April 6, 2006 06:45 AM UTC

Hi Nik, You could customize the context menu to display the name of the selected node when right clicked on it by handling the MouseDown Event handler. Code: private void treeViewAdv1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button==MouseButtons.Right) { //Clear the contextMenu Menuitems ,so that only the SelectedNode text get displayed this.contextMenu1.MenuItems.Clear(); this.treeViewAdv1.SelectedNode=this.treeViewAdv1.GetNodeAtPoint(new Point(e.X,e.Y)); //If the selected node is not equal to null, create MenuItem if(this.treeViewAdv1.SelectedNode!=null) { //Create MenuItem for the SelectedNode MenuItem menuitem=new MenuItem(this.treeViewAdv1.SelectedNode.Text); this.contextMenu1.MenuItems.Add(menuitem); } } } Please take a look at the attached sample which illustrates this above functinality. Let me know if this helps you. Thanks for your interest in Syncfusion products. Kind Regards, Deepa.


Administrator [Syncfusion]
Replied On April 6, 2006 09:09 AM UTC

Thanks for the sample and for the quick response. I was struggling with this for a long time. regards, Nik


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon