本文介绍了如何启用/禁用menustrip项目的侧面mdiparent表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 这是我尝试但它给出了nullexception错误。 i想要在成功登录后启用homemenustrip。请帮助 我尝试过: MDIParen.cs: - private void adminToolStripMenuItem_Click (对象发送者,EventArgs e)// admin是menustrip,因为他们是登录和家庭条。 { if(loginToolStripMenuItem.Enabled == true) { homeToolStripMenuItem.Enabled = false; } else { homeToolStripMenuItem.Enabled = true; } } } } Login.cs: - 公共部分类登录:形式 { public loginpg() { InitializeComponent(); } private void loginbutton_Click(object sender,EventArgs e ) { if(usertxt.Text ==arjun&& passwordtxt.Text ==12345) { homepg H =新homepg(); H.Show(); this.Hide(); MDIParent1 M = new MDIParent1(); M.Controls [loginToolStripMenuItem]。Enabled = false; / / Nullexception } } 解决方案 this is what i tried but its giving nullexception error.i want to enable homemenustrip after succesfull login.please helpWhat I have tried:MDIParen.cs:- private void adminToolStripMenuItem_Click(object sender, EventArgs e)//admin is menustrip under that their is login and home strips. { if (loginToolStripMenuItem.Enabled == true) { homeToolStripMenuItem.Enabled = false; } else { homeToolStripMenuItem.Enabled = true; } } }}Login.cs:- public partial class loginpg : Form { public loginpg() { InitializeComponent(); } private void loginbutton_Click(object sender, EventArgs e) { if (usertxt.Text=="arjun" && passwordtxt.Text=="12345") { homepg H = new homepg(); H.Show(); this.Hide(); MDIParent1 M =new MDIParent1(); M.Controls["loginToolStripMenuItem"].Enabled = false;// Nullexception here } } 解决方案 这篇关于如何启用/禁用menustrip项目的侧面mdiparent表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-23 11:00