I. Overview
You can open a menu to users by storing commands grouped by general themes.
The menustrip control is a new feature in this version of Visual Studio and. NET Framework. With this control, you can easily create a menu like this in Microsoft Office.
The menustrip control supports multi-Document Interface (MDI) and menu merging, tooltip, and overflow. You can enhance menu availability and readability by adding access keys, shortcuts, selected tags, images, and separators.
The menustrip control replaces the mainmenu control and adds features to it. However, you can also choose to retain the mainmenu Control for backward compatibility and future use.
Ii. Usage and related attributes
You can use the menustrip control:
Create easy-to-Customize common menus that support advanced user interfaces and la s, such as text and image sorting and alignment, drag-and-drop operations, MDI, overflow, and other modes for accessing menu commands.
Supports typical operating system appearances and behaviors.
Event consistency processing is performed on all containers and items. The processing method is the same as that of other controls.
The following table shows some important attributes of menustrip and associated classes.
Attribute |
Description |
Mdiwindowlistitem |
Gets or sets the toolstripmenuitem used to display the list of MDI child forms. |
System. Windows. Forms. toolstripitem. mergeaction |
Obtains or sets how the child menu and parent menu of the MDI application are merged. |
System. Windows. Forms. toolstripitem. mergeindex |
Obtain or set the position of the merge items in the menu of the MDI application. |
System. Windows. Forms. Form. ismdicontainer |
Gets or sets a value indicating whether the form is a container of the MDI child form. |
Showitemtooltips |
Gets or sets a value indicating whether it is a tooltip for menustrip display. |
Canoverflow |
Gets or sets a value that indicates whether menustrip supports the overflow function. |
Shortcutkeys |
Gets or sets the shortcut keys associated with toolstripmenuitem. |
Showshortcutkeys |
Gets or sets a value that indicates whether the shortcut keys associated with toolstripmenuitem are displayed next to toolstripmenuitem. |
Iii. Simple instances
Below is a simple demonstration of the features of menustrip:
1. The overall red line represents menustrip:
2. A specific menu item is called toolstripmenuitem:
3. You can edit the menu items:
4. menu item separation line. When editing a menu item, enter:
5. the shortcut keys for menu items can be expressed in (& letters) and set through the shotcutkey attribute.
6. Set the icon for the menu item:
Note: To compare the two shortcut key settings, you 'd better try it yourself:
7. Add the exit window code for the exit button:
C # control menustrip ()