c# - Menu click causes form to "lose focus" and menu dropdown disappears -


I have ContextMenuStrip or MenuStrip . I do not really know what is happening because of this, so to see any of the following, a repeat test should be prepared:

I have created two Windows Forms: Form1 and Form2 . Both have been linked to a menu strip . Both are set to StartPosition = CenterScreen .

Form 1 is a simple menu like this: Form2 & gt; Open . Clicking on "Open" will launch Form2 .

Form2 is such a simple menu: try to open & gt; Other TestMenuites

  1. Launch the program form1
  2. Open form2 to form1 (that is, form2 & gt; open ].
  3. Form2 appears. Try opening form2 , menustrip at
  4. > (try opening / Code>). Form1 again looks at form2 , although form2 is still a focus (you can see it if you select Form2 a bit

If I for the owner of form2 to form1 , form2 Setting> When You Trying Step 4 , Then remains visible, but the menu does not appear for the first time after all the other clicks appear to be OK.

While trying to open a context menu (on another form opened on another form) See, and it will disappear immediately, but only for the first time. After this every time it will open normally. Do anyone have any idea what is happening?

Yes, it's RTM version of .NET 4.5 Is known bug. This is mentioned:

When you click on a menu item to open a child window in the app, interactions with the menu and the child window behave incorrectly. For example, the following:
- When you open a shortcut menu in the child window, the main window takes the form focus.
- You can not use mnemonics to access menu items.

As you can tell from the KB article, this bug was fixed quite a while ago. Bug fixes were included in the maintenance release, which was available on January 8, 2013 for the first time. Make sure that Windows updates allow you to deploy that update on your machine. Or download it.


Comments