First, I’ll describe what I’ve got, and then I’ll ask the question, to everyone who read to the end a huge thank you. The question may seem silly, but google did not find the answer to it and can’t do anything, infuriates to the horror, but I have to write a diploma)) help good people.

There is a C # Windows Form project. I am writing in Visual Studio 2012

There is a main form FormMain on it menu (StripMenu) on which there are items "file", "service", "help", etc.

There is also a second form, FormProperties, which opens when you click on "service" -> "properties" in the menu (StripMenu) of the first form, with the following code

FormProperties formProperties = new FormProperties(); // просто создаем экземпляр formProperties.Show(); // и не модально открываем 

In the second form, there is also a menu with the item "operations" in which there are sub-items "open", "add", etc.

Actually the question: Who can explain such incomprehensible behavior as, when you click on the "operation" for the FIRST time, the form remains in focus, is drawn for some reason under the calling FormMain, i.e. if the FormProperties form is scrambled with the mouse for the title and start to drive it across the screen, then when intercepting with the first form, it is covered up by it (the first form is drawn from above), although the first form is not in focus, when you click the second and subsequent times, the submenu opens, as it should be, the first form remains in the background. Why??!!

  • at random calculated that this behavior occurs if the form is called from the submenu, i.e. not immediately by clicking on the menu button (StripMenu), but when called from the drop-down submenu. For example, if you just call from "service", then everything is fine, and if from "service" -> "properties" it is crookedly drawn. Some kind of heresy - Sergey041691
  • Hm If the Owner trick failed (did you try?), Try manually closing the menu before creating a new window. - VladD
  • (manually == programmatically, without waiting until it closes itself with a loss of focus) --- I’m running out of comments, I’ll delete the upper ones - VladD
  • Can you tell me how to programmatically minimize a submenu? Something I can not find for this method, where to look even in the ToolStripItemCollection? - Sergey041691
  • No, I do not know. You can try to set the focus on some element (of those that take focus, of course) - for example, the one that has local focus in the first form. Loss of focus should cause the closure of the drop-down menu, in theory. - VladD

0