本文介绍了禁用和启用Mdiparent Toolstrip菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是C#中的新手,并在该表单工具栏菜单项中创建了Mdiparent表单.登录菜单,菜单项,事务处理...当我打开表单时打开它,并且其他菜单项已启用(以前被禁用).. 这是登录表单代码:
I''m a new in C# and creating Mdiparent form in that form toolstrip menu items are Login,Invoice,Transaction like...when I login form open it opened and other menu items are Enabled(previously disabled).. This is login form code:
private void login_Click(object sender, EventArgs e) { bool flag = false; try { System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = BillingApplication.Properties.Settings.Default.DB_BillingConnectionString; conn.Open(); string selectString = "SELECT * FROM login WHERE (Username = '" + textBox1.Text + "' AND Password = '" + textBox2.Text + "')"; OleDbCommand cmd = new OleDbCommand(selectString, conn); OleDbDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { flag = true; } } } catch (Exception) { MessageBox.Show("Error with Database Connection"); } if (flag == true) { frmLogin login = new frmLogin(); login.Hide(); foreach (Form form in Application.OpenForms) { if (form.GetType() == typeof(MDIParent1)) { form.Activate(); return; } } } }推荐答案
主要形式代码 Main Form Code private void frmMain_Load(object sender, EventArgs e) { this.Hide(); DialogResult dr; frmLogin lStudent = new frmLogin(); dr = lStudent.ShowDialog(this); lStudent.Dispose(); if (dr != System.Windows.Forms.DialogResult.OK) this.Dispose(); else this.Show(); }
登录表单代码
Login Form Code
string u = "tochal",p="1357"; if (txtUserName.Text == u && p == txtPassword.Text) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Dispose(); }
更多推荐
禁用和启用Mdiparent Toolstrip菜单项
发布评论