禁用和启用Mdiparent Toolstrip菜单项

编程入门 行业动态 更新时间:2024-10-09 12:33:42
本文介绍了禁用和启用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菜单项

本文发布于:2023-11-28 10:38:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642057.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:菜单项   Mdiparent   Toolstrip

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!