1
votes

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 menu list?

Requirements:
- This child form has to be an MDI child.
- This forms is always at the bottom of the MDI form stack.

1

1 Answers

1
votes

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);