This page looks best with JavaScript enabled

Migration issue of MainMenu to MenuStrip

 ·   ·  ☕ 1 min read

Suppose you were lucky to find this article and already resolved all your compile time errors. I found an issue that may require redesign of your application, even though everything else appears to be working fine. I’ll put it straight: MenuStrip/ToolStripMenuItem pair is not 100% backwards compatible with MainMenu/MenuItem. One particular thing is how keyboard shortcuts work.

In MainMenu concept, triggering a shortcut by pressing a hotkey combination causes .NET framework to open the corresponding menu under the hood, process Popup event and only then click the MenuItem. Starting from .NET 2.0 and MenuStrip class, it no longer does that. What it means to you, a .NET developer, is that you cannot use Popup event to control availability of menu options at runtime. For example, if popup of your File menu causes your Save and Save As to be enabled or disabled, depending on whether they apply to current context - the approach will no longer work. I also researched this question with Devexpress components, those guys do it like .NET 2.0. So if you heavily rely on Popup event, you need a redesign, whether you stick with Microsoft, or go Devexpress. Sample project is attached. It compares .NET 1.1, .NET 2.0 and latest Devexpress in regard to described approach.

Victor Zakharov
Victor Zakharov
Web Developer (Angular/.NET)