8.6 Creating Context Menus

 <  Day Day Up  >  

8.6 Creating Context Menus

You want a context menu to display whenever a user right-clicks on a control or on your Windows Form.


Technique

To create a context menu, drag a ContextMenu control from the form designer toolbox and drop it on your form. Design the menu using the menu editor as described in the previous recipe. To associate a context menu with a control, select the control that you want to attach the context menu to in the form designer and change the ContextMenu property of that control. The property browser enumerates any available context menus that you have created and lists them in the ContextMenu property drop-down selection box.

Comments

In addition to a main menu, you can also create smaller control-specific context menus that appear whenever a user right-clicks on a control or your form. Using the same menu editor as the MainMenu control, you can create a small or extremely sophisticated context menu. Furthermore, you can also associate the context menu with any number of your controls on your form.

A major difference within the form designer between a MainMenu control and a ContextMenu control is that a ContextMenu control isn't always displayed within the editor. Because both types of menus occupy the same space within the form designer, one of them has to remain hidden while the other is being edited. When no menus are selected, the MainMenu control is visible within the forms designer. To edit an existing ContextMenu control, select its nonvisual representation at the bottom of the form designer. This action replaces the MainMenu within the form with the ContextMenu and opens the in-place menu editor, allowing you to add or delete menu items.

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net