Compartilhar via


MenuStrip Control Overview (Windows Forms)

Menus expose functionality to your users by holding commands that are grouped by a common theme.

The MenuStrip control is new to this version of Visual Studio and the .NET Framework. With the control, you can easily create menus like those found in Microsoft Office.

The MenuStrip control supports the multiple-document interface (MDI) and menu merging, tool tips, and overflow. You can enhance the usability and readability of your menus by adding access keys, shortcut keys, check marks, images, and separator bars.

The MenuStrip control replaces and adds functionality to the MainMenu control; however, the MainMenu control is retained for backward compatibility and future use if you choose.

Ways to Use the MenuStrip Control

Use the MenuStrip control to:

  • Create easily customized, commonly employed menus that support advanced user interface and layout features, such as text and image ordering and alignment, drag-and-drop operations, MDI, overflow, and alternate modes of accessing menu commands.

  • Support the typical appearance and behavior of the operating system.

  • Handle events consistently for all containers and contained items, in the same way you handle events for other controls.

The following table shows some particularly important properties of MenuStrip and associated classes.

Property Description

MdiWindowListItem

Gets or sets the ToolStripMenuItem that is used to display a list of MDI child forms.

System.Windows.Forms.ToolStripItem.MergeAction

Gets or sets how child menus are merged with parent menus in MDI applications.

System.Windows.Forms.ToolStripItem.MergeIndex

Gets or sets the position of a merged item within a menu in MDI applications.

System.Windows.Forms.Form.IsMdiContainer

Gets or sets a value indicating whether the form is a container for MDI child forms.

ShowItemToolTips

Gets or sets a value indicating whether tool tips are shown for the MenuStrip.

CanOverflow

Gets or sets a value indicating whether the MenuStrip supports overflow functionality.

ShortcutKeys

Gets or sets the shortcut keys associated with the ToolStripMenuItem.

ShowShortcutKeys

Gets or sets a value indicating whether the shortcut keys that are associated with the ToolStripMenuItem are displayed next to the ToolStripMenuItem.

The following table shows the important MenuStrip companion classes.

Class Description

ToolStripMenuItem

Represents a selectable option displayed on a MenuStrip or ContextMenuStrip.

ContextMenuStrip

Represents a shortcut menu.

ToolStripDropDown

Represents a control that allows the user to select a single item from a list that is displayed when the user clicks a ToolStripDropDownButton or a higher-level menu item.

ToolStripDropDownItem

Provides basic functionality for controls derived from ToolStripItem that display drop-down items when clicked.

See Also

Reference

ToolStrip
MenuStrip
ContextMenuStrip
StatusStrip
ToolStripItem
ToolStripDropDown