开发者

Prevent MDI window to appear in the Window menu list

I have a .NET MDI application that uses the MDI Window List to automatically populate child MDI forms into the Window menu.

Is it possible to prevent certain MDI child forms not be included in this automatic me开发者_Go百科nu list?

Requirements:

- This child form has to be an MDI child.

- This forms is always at the bottom of the MDI form stack.


You should handle the DropDownOpening event of the menu item, and remove the unwanted item from the list. Something like this:

MenuStrip ms = new MenuStrip();
ToolStripMenuItem windowMenu = new ToolStripMenuItem("Window");
ms.MdiWindowListItem = windowMenu;

windowMenu.DropDownOpening += (sender, e) =>
        {
            if (windowMenu.DropDownItems.Count > 0)
                windowMenu.DropDownItems.RemoveAt(0);
        };

ms.Items.Add(windowMenu);
ms.Dock = DockStyle.Top;            
this.MainMenuStrip = ms;
this.Controls.Add(ms);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜