Podcast
Questions and Answers
What is the primary purpose of using a Menu in an application?
What is the primary purpose of using a Menu in an application?
How can you add a menu strip to a form?
How can you add a menu strip to a form?
What is the purpose of the MainMenuStrip property?
What is the purpose of the MainMenuStrip property?
What type of items can be added to a top-level menu using the Windows Forms Designer?
What type of items can be added to a top-level menu using the Windows Forms Designer?
Signup and view all the answers
What is the purpose of the ShortcutKeys property?
What is the purpose of the ShortcutKeys property?
Signup and view all the answers
What is the purpose of underlining the subsequent character when including an '&' in a text property?
What is the purpose of underlining the subsequent character when including an '&' in a text property?
Signup and view all the answers
What determines the subset of menu commands displayed in a context menu?
What determines the subset of menu commands displayed in a context menu?
Signup and view all the answers
What is the purpose of a Tool Strip?
What is the purpose of a Tool Strip?
Signup and view all the answers
What is stored in the ContextMenuStrip property?
What is stored in the ContextMenuStrip property?
Signup and view all the answers
How do users typically display a context menu?
How do users typically display a context menu?
Signup and view all the answers
Study Notes
Menu
- Menus are used to provide functionalities without cluttering the UI.
- A MenuStrip component can be added to a form by dragging it from the Toolbox.
Building a Menu Strip
- The MenuStrip Designer allows building a menu strip interactively using its design surface.
Multiple Menu Strips
- A form can host one or more menu strips, all of which can be visible at run time.
- A menu strip can be hidden or shown by setting its Visible property.
Main Menu Strip
- A form's MainMenuStrip property specifies which menu strip receives shortcut keys (Alt+...).
- The Windows Forms Designer automatically sets MainMenuStrip in InitializeComponent to the first menu strip dropped onto a form.
Menu Strip Items
- A MenuStrip control can contain zero or more top-level menus via its Items property, which is of type ToolStripItemCollection.
- The Designer automatically adds a ToolStripMenuItem by default.
- Other types of toolstrip items can be added, including ToolStripComboBox, ToolStripTextBox, and ToolStripSeparator.
- Properties of menu strip items include:
- Checked and CheckOnClick to mark an item as chosen and determine whether it can be checked.
- Enabled and Visible to determine whether the item can be chosen or whether it will be shown.
- Image to assign images to strip items.
- MergeAction and MergeIndex for MDI-related properties.
- ShortcutKeys to assign a keyboard shortcut to a menu item.
Menu Item Text
- The Text property specifies the text shown to the user.
- Including an "&" (ampersand) in the Text property underlines the subsequent character and provides a visual cue for keyboard menu navigation via the Alt key.
- TextAlign and TextImageRelation specify text alignment with or without an image.
Context Menu
- Context menus provide a subset of available menu commands specific to the current activity on a form.
- Forms and controls can have at most one context menu each, specified by the ContextMenuStrip property.
Tool Strip
- Tool strips provide quick access to commonly used commands as single-click buttons.
- They are useful when menu items are deeply hidden within a menu strip hierarchy.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Learn how to use menus to provide functionalities without cluttering the UI. Discover how to add a menu strip to your form and build a menu interactively using the MenuStrip Designer.