Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between .ContextMenu and .ContextMenuStrip

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?

like image 545
thenonhacker Avatar asked Dec 09 '11 07:12

thenonhacker


People also ask

What is the difference between MenuStrip and ContextMenuStrip?

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.

What is a ContextMenuStrip?

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.

Which of the following represents a shortcut menu a ContextMenuStrip B ContextMenuStrip C ContextMenuStrip D ContextMenuStrip?

ContextMenuStrip replaces ContextMenu. You can associate a ContextMenuStrip with any control, and a right mouse click automatically displays the shortcut menu.

Which property we have to set to use the ContextMenuStrip?

The Items property is used to add and work with items in a ContextMenuStrip.


2 Answers

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 ContextMenuStrip control takes a good idea and makes it better. It works just like the ContextMenu control. You still attach a ContextMenuStrip control to another user control by changing that control’s ContextMenuStrip property. However, Microsoft has substantially improved the features you can add to a ContextMenuStrip cont...

Look at the examples at MSDN:

http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip.aspx

ContextMenuStrip replaces ContextMenu. You can associate a ContextMenuStrip with any control, and a right mouse click automatically displays the shortcut menu. You can show a ContextMenuStrip programmatically by using the Show method. ContextMenuStrip supports cancelable Opening and Closing events to handle dynamic population and multiple-click scenarios. ContextMenuStrip supports 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 ContextMenu has also been assigned to the control, the ContextMenu takes precedence over the ContextMenuStrip.

like image 104
punker76 Avatar answered Oct 23 '22 11:10

punker76


From the doc

ContextMenuStrip replaces ContextMenu.

like image 22
shahkalpesh Avatar answered Oct 23 '22 10:10

shahkalpesh