防止MDI窗口出现在“窗口"菜单列表中 [英] Prevent MDI window to appear in the Window menu list

查看:73
本文介绍了防止MDI窗口出现在“窗口"菜单列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET MDI应用程序,该应用程序使用 MDI窗口列表自动将子MDI表单填充到窗口"菜单中.

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

是否可以防止某些MDI子窗体不包括在此自动菜单列表中?

Is it possible to prevent certain MDI child forms not be included in this automatic menu list?

要求:
-此子表格必须是MDI子表格.
-此表单始终位于MDI表单堆栈的底部.

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

推荐答案

您应该处理菜单项的DropDownOpening事件,然后从列表中删除不需要的项.像这样:

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

这篇关于防止MDI窗口出现在“窗口"菜单列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆