C # How to Use menus

Source: Internet
Author: User

1. Source Code
Private void toolstripmenuitem#click (object sender, EventArgs e)
{
// Click expand (close) to show other events
Switch (I)
{
Case 1:
This. Set the password ToolStripMenuItem. Visible = false;
This. Add User ToolStripMenuItem. Visible = false;
This. forgot password ToolStripMenuItem. Visible = false;
This. Change the password ToolStripMenuItem. Visible = false;
This. Employee input ToolStripMenuItem. Visible = false;
I = 2;
This. Operate ToolStripMenuItem. ShowDropDown ();
Break;

Case 2:
This. Set the password ToolStripMenuItem. Visible = true;
This. Add User ToolStripMenuItem. Visible = true;
This. forgot password ToolStripMenuItem. Visible = true;
This. Change the password ToolStripMenuItem. Visible = true;
This. Employee input ToolStripMenuItem. Visible = true;
I = 1;
This. Operate ToolStripMenuItem. ShowDropDown ();
Break;
}
}

2. If the menu is Visible only when the initial form is used, you only need to set the Visible attribute of the menu item,

3. The special point here is this. Operate ToolStripMenuItem. ShowDropDown ();
When this sentence is left blank, the system automatically closes the menu after clicking it. It is deemed that the execution of the button event has ended, and the menu cannot be refreshed. You need to click the menu to observe it. After this sentence is added, the menu is updated and not closed, you can directly view the menu changes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.