See Also: ContextMenuStrip Members
System.Windows.Forms.ContextMenuStrip replaces System.Windows.Forms.ContextMenu. You can associate a System.Windows.Forms.ContextMenuStrip with any control, and a right mouse click automatically displays the shortcut menu. You can show a System.Windows.Forms.ContextMenuStrip programmatically by using the ToolStripDropDown.Show method. System.Windows.Forms.ContextMenuStrip supports cancelable ToolStripDropDown.Opening and ToolStripDropDown.Closing events to handle dynamic population and multiple-click scenarios. System.Windows.Forms.ContextMenuStrip supports images, menu-item check state, text, access keys, shortcuts, and cascading menus.
The following items are specifically designed to work seamlessly with both System.Windows.Forms.ToolStripSystemRenderer and System.Windows.Forms.ToolStripProfessionalRenderer in all orientations. They are available by default at design time for the System.Windows.Forms.ContextMenuStrip control:
Shortcut menus are typically used to combine different menu items from a System.Windows.Forms.MenuStrip of a form that are useful for the user given the context of the application. For example, you can use a shortcut menu assigned to a System.Windows.Forms.TextBox control to provide menu items for changing the font of the text, finding text within the control, or Clipboard features for copying and pasting text. You can also expose new System.Windows.Forms.ToolStripMenuItem objects in a shortcut menu that are not located within a System.Windows.Forms.MenuStrip to provide situation-specific commands that are inappropriate for the System.Windows.Forms.MenuStrip to display.
Typically, a shortcut menu is displayed when a user clicks the right mouse button over a control or the form itself. Many visible controls, as well as the System.Windows.Forms.Form itself, have a Control.ContextMenuStrip property that binds the System.Windows.Forms.ContextMenuStrip class to the control that displays the shortcut menu. More than one control can use a System.Windows.Forms.ContextMenuStrip.
Set the ToolStripDropDownMenu.ShowCheckMargin property to true to add space to the left of a System.Windows.Forms.ToolStripMenuItem for a check mark that shows that the menu item is enabled or selected. The ToolStripDropDownMenu.ShowImageMargin property is set to true by default. Use this space to the left of the System.Windows.Forms.ToolStripMenuItem to display an image for that menu item.
Although System.Windows.Forms.ContextMenuStrip replaces and adds functionality to the System.Windows.Forms.ContextMenu control of previous versions, System.Windows.Forms.ContextMenu is retained for both backward compatibility and future use if so desired.