简体   繁体   English

检测对MDI子项的更改

[英]Detecting changes to MDI child

Is there a way to detect changes to MDI child when one of the child is closed? 当一个孩子关闭时,是否有办法检测MDI孩子的变化?

I'm trying to create a dynamic dropdown menu item in the toolstrip menu item that can be add or remove programatically from the MDI child. 我试图在工具栏菜单项中创建一个动态下拉菜单项,该菜单项可以以编程方式从MDI子项添加或删除。

Because of the instance is dispose when the child is close,i couldn't cross check with the toolstrip menu item.The adding part is successful but the removing part is a problem. 由于实例是在孩子关闭时被处置的,所以我无法与toolstrip菜单项进行交叉检查。添加部分成功但是移除部分是一个问题。

            ToolStripMenuItem temp = new ToolStripMenuItem();
            if(form.Visible == true)
            {
                this.SuspendLayout();
                temp.Name = form.Text;
                temp.Size = new System.Drawing.Size(112, 22);
                temp.Text = form.Text;

                this.windowsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { temp });
                this.ResumeLayout();
            }

You should use FormClosing event. 您应该使用FormClosing事件。 It executes before disposing the instance of the form. 它在处理表单实例之前执行。 FormClosed event fires after disposing of the form's instance. 处置表单实例后,将引发FormClosed事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM