How to: Attach a Shortcut Menu to a TreeNode Using the Designer
The Windows Forms TreeView control displays a hierarchy of nodes, similar to the files and folders displayed in the left pane of the Windows Explorer feature in Windows operating systems. By setting the ContextMenuStrip property, you can provide context-sensitive operations to the user when they right-click the TreeView control. By associating a ContextMenuStrip component with individual TreeNode items, you can add a customized level of shortcut menu functionality to your TreeView controls.
To associate a shortcut menu with a TreeNode at design time
Add a TreeView control to your form, and then add nodes to the TreeView as needed. For more information, see How to: Add and Remove Nodes with the Windows Forms TreeView Control.
Add a ContextMenuStrip component to your form, and then add menu items to the shortcut menu that represent node-level operations you wish to make available at run time. For more information, see How to: Add Menu Items to a ContextMenuStrip.
Reopen the TreeNodeEditor dialog box for the TreeView control, select the node to edit, and set its ContextMenuStrip property to the shortcut menu that you added.
When this property is set, the shortcut menu will be displayed when you right-click the node.
Additionally, you will want to write code to handle the Click events for these menu items.
See also
.NET Desktop feedback