I have noticed some strange form interactions while using a ContextMenuStrip
or a MenuStrip
. I don't really know what is causing it so the following should create a repeatable test for anyone looking into this:
I've created two Windows Forms: Form1
and Form2
. Both have a MenuStrip
added to them. Both are set to StartPosition
= CenterScreen
.
Form1
has a simple menu like this: Form2 > Open
. Clicking "Open" will launch Form2
.
Form2
has a simple menu like this: Try to open > anotherTestMenuItem
- Start the program.
Form1
opens. - Open
Form2
fromForm1
(i.e. clickForm2 > Open
). Form2
appears.- On
Form2
, try to open theMenuStrip
(clickTry to open
).Form1
will reappear overForm2
, althoughForm2
still has focus (you can see this if you moveForm2
a little before trying to open the menu).
If I set Form2
's owner to Form1
, Form2
remains visible when you try Step 4, but the menu doesn't display the first time. All subsequent clicks seem fine.
I noticed this when I tried opening a context menu (on a form opened by another form) and it would disappear immediately, but only the first time. Every time thereafter it would open normally.
Does anyone have any ideas as to what is going on?