Changes

Jump to: navigation, search

Creating Context Menus in C Sharp

31 bytes added, 13:48, 19 March 2009
Adding Context Menus to a C# Form
The purpose of this example is to create a context menu on form which will contain options to hide and show the ''MyTextBox'' object. From the Visual Studio Toolbox, double click on the ''ContextMenuStrip'' object. The object will be added to the form. You will notice, however, that since the menu is not located at any specific position in the form, it is located in the panel beneath the form. To display the menu in the form, or edit properties of the object, simply click on this instance of the object. With the object selected, change the name to ''TextBoxMenu'' by changing the ''Name'' property in the Properties panel. You will notice also, that a representation of the context appears in the form area:
<google>ADSDAQBOX_FLOW</google>
[[Image:visual_basic_new_context_menu.jpg]]
Once an item has been added to the menu right clicking on the item provides a list of properties which may be changed, such as making an item checkable, or disabling an item so that it cannot be selected by the user. It is also possible to define an image to be displayed for the menu option.
To complete this phase of the tutorial, add menu items labeled ''Hide'' and ''Show''.
== Associating a Component with a Context Menu ==

Navigation menu