Record: my menu bar (1)

Source: Internet
Author: User

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1925222409-0.gif "alt =" j_0001.gif "/>

The menu bar consists of the main menu and context menu. The main menu has only one page, while the context menu is different and can have many. The context menu is a menu bar that appears when you move the mouse over the control and right-click it. This menu bar is called the context menu bar.

In fact, it is not difficult to create a menu bar, that is, a MenuStrip control in the menu and toolbar. This control does not have many attributes. You can try it one by one. How can I know this without trying it myself? Are you heading for it! I guess it's just a coincidence.

650) this. width = 650; "src =" http://img1.51cto.com/attachment/201310/123811653.png "title =" Capture. PNG "alt =" 123811653.png"/>

This is a simple menu bar. In the context menu bar, you need to drag another control: ContextMenuStrip. And then set its attributes one by one. It mainly sets the sub-menu items under these controls:

// Set the function of saving in the menu private void to save ToolStripMenuItem_Click (object sender, EventArgs e) {// The system prompts the user whether to save and continues executing DialogResult dr = MessageBox based on the user's choice. show ("Save changes? "," Message ", MessageBoxButtons. yesNoCancel, MessageBoxIcon. question, MessageBoxDefaultButton. button1); if (dr = DialogResult. yes) {MessageBox. show ("save");} else if (dr = DialogResult. no) {MessageBox. show ("not saved");} else {MessageBox. show ("cancel Operation") ;}} private void exit XToolStripMenuItem_Click (object sender, EventArgs e) {this. close () ;}// set the event private void maximization ToolStripMenuItem_Click (ob Ject sender, EventArgs e) {this. windowState = FormWindowState. maximized;} private void minimize ToolStripMenuItem_Click (object sender, EventArgs e) {this. windowState = FormWindowState. minimized;} private void save ToolStripMenuItem1_Click (object sender, EventArgs e) {save volume (sender, e);} private void exit ToolStripMenuItem_Click (object sender, EventArgs e) {exit Queue (Sender, e) ;}/// <summary> /// whether minimized or maximized, the Resize event // </summary> // <param name = "sender"> </param> // <param name = "param name = "e"> </param> private void Form1_Resize (object sender, eventArgs e) {// if the window state is minimized, display the tray icon and hide the form if (this. windowState = FormWindowState. minimized) {policyicon1.visible = true; this. visible = false;} else {policyicon1.visible = false;} private void noti FyIcon1_DoubleClick (object sender, EventArgs e) {this. visible = true; this. windowState = FormWindowState. normal; this. activate (); policyicon1.visible = false;} // <summary> // double-click the event and press the Left or Right button. Double-click event, regardless of the left and right keys. // </summary> /// <param name = "sender"> </param> /// <param name = "e"> </param> private void policyicon1_mousedoubleclick (object sender, mouseEventArgs e) {// if you double-click the mouse button, perform the following operations if (e. button = MouseButtons. left) {// make the form visible this. visible = true; // set the status of the form to normal this. windowState = FormWindowState. normal; // obtain the focus of the form. this. activate (); // hide the tray icon policyicon1.visible = false;} private void exit toolstripmenuitem#click (object sender, EventArgs e) {// exit Application. exit ();} private void display ToolStripMenuItem_Click (object sender, EventArgs e) {// enable the options in the following menu to implement the "display" event notifyIcon1_DoubleClick (sender, e );}

Let's talk about some small issues. The tray control displays an image under the current form on the desktop to facilitate user operations.

P.S:Common forms

Attribute:

Topmost --> keep the form at the front end

WindowState --> indicates that the status of the form is maximized, minimized, and normal)

Event:

Load --> the last triggered event before the form is displayed. We usually assign values and initialize the control mentioned in this event.

Activated --> the form is activated.

Deactivate --> A form is disabled.

Formclosing --> triggers an event before the form enters the close process.

Resize --> triggered when the window size is changed.

Method:

Close --> close the window. You can also use Application. Exit () -- to close the Application)

Show --> displays a non-modal window.

ShowDialog --> display a modal window.

Hide --> Hide the window. This method is available for almost all forms/buttons)

Focus --> get Focus.

SelectedAll --> select all.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/19252211M-2.gif "alt =" j_0047.gif "/>

Ajax Girl, come on!

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/19252211M-2.gif "alt =" j_0047.gif "/>


This article is from the "Ajax girl" blog!

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.