【发布时间】:2014-12-30 03:12:25
【问题描述】:
我有一个带有条形菜单的父表单,名为topMenu。
我有一个名为“SignIn”的子表单,当用户登录时,我想禁用topMenu.item.logIn 并启用topMenu.item.Logout。
如何从子窗体中禁用父容器的topMenu?
当用户单击条形菜单项“登录”时,将执行以下代码。
private void signInToolStripMenuItem_Click(object sender, EventArgs e)
{
var newMDIChild = new SignIn();
// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;
newMDIChild.Dock = DockStyle.Fill;
// Display the new form.
newMDIChild.Show();
}
用户输入用户名和密码后,将执行以下代码
public partial class SignIn : Form
{
public SignIn()
{
InitializeComponent();
}
private void btn_signin_Click(object sender, EventArgs e)
{
UserInfo.Autherized = true;
// here I want to disable the sign in menu item
// and enable the sign out menu item which is located on the parent form
this.Close();
}
}
【问题讨论】:
-
登录是标准形式,一旦登录成功,我想禁用菜单项。你的意思是我可以重新加载父表单并在加载方法中处理条件?
-
来自顶部的条形菜单。
-
什么代码?当用户单击它时,它只是菜单中的一个项目,它会打开一个子表单。
标签: c# winforms mdi toolstripmenu