隐藏菜单条项目 [英] hide Menu strip items

查看:79
本文介绍了隐藏菜单条项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我有两种形式:登录表单和菜单表单,我想在与其他用户一起登录时从菜单表单中隐藏项目
我尝试了此方法,但是它不起作用:

Hi guys!

i have two forms: a login form and a menu form and i want when i log in with different user to hide items from menu form
i try this but it doesnt work:

private void button1_Click(object sender, EventArgs e)
      {
          if (username_txth.Text == username && password_txth.Text == password)
          {
              MessageBox.Show("You are now logedin as admin");
              Menu myNewForm = new Menu();

              myNewForm.Show();
              this.Hide();
              εισαγωγήToolStripMenuItem.Items.Enabled = false;

          }



我该怎么做?



how i can do this???

推荐答案

使用属性Visible:
http://msdn.microsoft.com/en-us/library/system.windows.forms.menuitem.visible.aspx [ ^ ].

—SA
Use the property Visible:
http://msdn.microsoft.com/en-us/library/system.windows.forms.menuitem.visible.aspx[^].

—SA


首先需要使用username_txth.Equals(username)
使用==表示它们是同一对象,而不是字符串是相同的值

再次显示该表单需要通过所有者(this)
first you need, username_txth.Equals(username)
using == means they are the same object, not that the strings are the same value

to show the form again need to pass the Owner (this)
MenuForm form = new MenuForm();
            form.Show(this);
            this.Hide();



3.在关闭或退出的应用程序上再次显示表单



3. show form again on closed or exit application

protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);
            this.Owner.Show();
        }



欢呼



cheers


这篇关于隐藏菜单条项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆