从另一个表单启用/禁用mdiparent的菜单项 [英] enable/disable menu items of mdiparent from another form

查看:99
本文介绍了从另一个表单启用/禁用mdiparent的菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个三张表格

mdiparent - 信息,登录表格和登出表格

当我使用正确的用户名和密码菜单登录mdiparent表格而非登录和注销菜单应启用true

i have a three form
mdiparent - information,login form and logout form
when i login with correct username and password menu on mdiparent form other than login and logout menu should enable true

推荐答案

您好,



在登录/注销表单加载事件中尝试此操作。< br $>


Hi,

try this in Login/logout form load event.

Control[] controls = this.MdiParent.Controls.Find("Menu", true);
            foreach (Control ctrl in controls)
            {
                if (ctrl.Name == "Menu")
                {
                    MenuStrip strip = ctrl as MenuStrip;
                    strip.Items["login"].Enabled = false;
                    strip.Items["logout"].Enabled = false;
                }
            }





或一旦你获得菜单控制,你可以启用/禁用你想要的任何东西,你可以改变。



希望它有所帮助。



or once you get the menu control, you can enable/disable anything you want, you can change.

hope it helps.








所以你需要一些代码才能这样做...





来自暴露的MDI两个菜单项目为公共,最初这两个菜单项目为禁用。



现在申请开始从MDI孩子开始登录并成功登录后

将login.parent转换为您的MDI并设置这两个菜单项启用。
Hi,


So you need some Code to do so...


In MDI from expose two menu Item as public and initially those two menu items as disable.

Now on application start open login from as MDI child and after successful login
cast login.parent as your MDI from and set those two menu Item enable.


这篇关于从另一个表单启用/禁用mdiparent的菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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