An example of creating a menu in C#. Control menuStrip
- Related topics
Search other websites:
Create an application like Windows Forms Application. On the application form to create a menu on the model, as shown in Figure 1.
Figure 1. The menu, which you need create
1. Run Microsoft Visual Studio. Create project using Windows Forms Application template
Detailed example of creating the application using Windows Forms Application template is described here. Save the project in any folder.
2. Control MenuStrip
To create the menu you need use the control MenuStrip. It is located on the Toolbox on the tab “Menus&Toolbars” (Fig. 2).
Figure 2. Control MenuStrip
After placing the component on the form (with the mouse) application form will look as shown in Figure 3. At the bottom of the form of designing an object with name menuStrip1 is placed. By using this name you can access to the properties and methods of the menu.
Figure 3. Application form after placement of MenuStrip
If you point by mouse on the item TypeHere of menu, then the button of pop-up menu will be appear. If you open the menu (mouse click), then you can select one of three controls in menu (Fig. 4):
- MenuItem – standard item of menu;
- ComboBox – the item of “drop-down list” type;
- TextBox – the control of “edit field” type.
In our case, we select first variant MenuItem.
Figure 4. The types of menu items
To create the submenu File you need to type “File” (Fig. 5). With the help of mouse and keyboard you can add items of menu. To delete the menu item, you need select it previously and press Delete button.
Figure 5. Creating submenu “File“
After creating all menu items, application form will have view as shown at Figure 6.
Figure 6. Application form after menu creating
Next steps are the programming the events, which will be generated when the user will select the particular menu item.
- Example of creating and calling a new form in C# application
- Windows Forms type Application Development in MS Visual Studio 2010