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
close icon

Customizing the context menu

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

2 Replies

DT Deepa TS Syncfusion Team 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.

CustomizeContextMenu.zip


AD Administrator Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon