我有一个带有条形菜单的父表单,名为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();
}
}