Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do Mnemonics work with ToolStrips?

Combined with or following the ALT key, mnemonics are one way to activate a ToolStripItem via keyboard. ToolStrip supports both explicit and implicit mnemonics. Explicit mnemonics are defined inline with the ampersand (&) character preceding the letter. Implicit mnemonics are determined by an algorithm wihin ToolStrips that attempts to find a matching item based on order of characters in the Text property.

Shortcuts

Shortcuts used by MenuStrips are different than ShortcutKeys used in MainMenu. One is a precombined list of keycombinations. MenuStrips simply use a combinations of the Keys enum (not order specific) to define the shortcut. In addition a provision is made to display a shortcutkey via text (e.g. Delete vs. Del) via the ShortcutDisplayString

Navigation

Alt activates the MenuStrip pointed to by Form.MainMenuStrip. From there, CTRL+TAB navigates between ToolStrips within ToolStripPanels. TAB and arrow keys are used to navigate between items in a ToolStrip. We use a special nearest item arrow handling algorithm in the Overflow to handle cross row navigation. Spacebar clicks ToolStripButton, ToolStripDropDownButton, ToolStripSplitButton.

Focus/Validation

For the most part, when activated by the menu key (ALT), the MenuStrip/ToolStrip will try not to take focus away from the control that is currently focus.  If there is a Control hosted within the MenuStrip or a dropdown off the MenuStrip, the Control will gain focus when tabbed to.  In general, the  GotFocus/LostFocus/Enter/Leave events on MenuStrip may not fire when keyboard activated.  In such cases, the MenuStrip.MenuActivate, MenuStrip.MenuDeactivate events can be used instead. 

By default ToolStrip.CausesValidation is false.  Validation can be performed by manually calling Validate() on the Form.