What are the differences between .ContextMenu and .ContextMenuStrip in Windows Forms?
I already know what a ContextMenu is, but how is ContextMenuStrip different from ContextMenu?
MenuStrip is used to add menu items on the form (along the top edge). ContextMenuStrip is used to add items that appear when you right-click on a control.
The ContextMenuStrip control represents a shortcut menu that pops up over controls, usually when you right click them. They appear in context of some specific controls, so are called context menus. For example, Cut, Copy or Paste options.
ContextMenuStrip replaces ContextMenu. You can associate a ContextMenuStrip with any control, and a right mouse click automatically displays the shortcut menu.
The Items property is used to add and work with items in a ContextMenuStrip.
http://www.informit.com/articles/article.aspx?p=606224&seqNum=2
You might wonder why Microsoft has replaced a valuable and popular control with a newcomer. The
ContextMenuStripcontrol takes a good idea and makes it better. It works just like theContextMenucontrol. You still attach aContextMenuStripcontrol to another user control by changing that control’sContextMenuStripproperty. However, Microsoft has substantially improved the features you can add to aContextMenuStripcont...
Look at the examples at MSDN:
http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip.aspx
ContextMenuStripreplacesContextMenu. You can associate aContextMenuStripwith any control, and a right mouse click automatically displays the shortcut menu. You can show aContextMenuStripprogrammatically by using the Show method.ContextMenuStripsupports cancelable Opening and Closing events to handle dynamic population and multiple-click scenarios.ContextMenuStripsupports images, menu-item check state, text, access keys, shortcuts, and cascading menus.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.contextmenustrip.aspx
If a
ContextMenuhas also been assigned to the control, theContextMenutakes precedence over theContextMenuStrip.
From the doc
ContextMenuStrip replaces ContextMenu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With