如何在mdiparent中启用和禁用menustrip [英] How to Enable and Disable the menustrip in mdiparent

查看:102
本文介绍了如何在mdiparent中启用和禁用menustrip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨frds,

我想启用和禁用mdiparent menustrip。在mdiparent表单内部没有mdi子表单打开意味着menustrip处于启用阶段。假设任何儿童形式处于开放状态意味着处于禁用阶段的menustrip。我怎么能这样做。

任何人都要尽快回复我。

谢谢

解决方案

MenuStrip 类有一个已启用 [ ^ ]属性,继承自 Control 类,这正是您所需要的。


< blockquote>将你的menustrip修饰符设置为Public并使用子代码下面的代码来禁用menustrip。



 Form1 parent =(Form1 ) this  .MdiParent; 
// parent.menuStrip1.Visible = false;
parent.menuStrip1。已启用= false ;







谢谢


在子项的Form_load事件中,禁用菜单或更好的方法,触发自定义事件ChildOpened。在FormClosed事件中,触发将在父窗体中捕获的另一个事件ChildClosed。



您可以通过在实例化子窗体时禁用菜单来避开第一个,但之前打开它。



根据MdiChildren系列,您可以使用

 menu.Enabled启用/禁用菜单=( this  .MdiChildren.Count ==  0 ); 


Hi frds,
I want to enable and disable the mdiparent menustrip. Inside the mdiparent form no mdi child form is open means the menustrip is in enable stage. Suppose anyone child form is in open means the menustrip in disable stage. How can I do this.
Anyone reply me as soon as possible.
Thanks

解决方案

MenuStrip class has a Enabled[^] property, inherited from Control class, which is exactly what you need.


Make your menustrip modifier to "Public" and use below code in child form to disable menustrip.

Form1 parent = (Form1)this.MdiParent;
//parent.menuStrip1.Visible = false;
parent.menuStrip1.Enabled= false;




Thanks


In Form_load event of the child, disable menu or better yet, fire custom event ChildOpened. In FormClosed event, fire another event ChildClosed that will be caught in the parent form.

You can avoid first one by disabling the menu when you instantiate child form, but before opening it.

Based on MdiChildren collection you can then enable/disable menu with

menu.Enabled = (this.MdiChildren.Count == 0);


这篇关于如何在mdiparent中启用和禁用menustrip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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