menustrip
1. 拖动menustrip到设计窗口
2. 编辑弹出和退出两个菜单,设置快捷键需要在前面加&
3. 给弹出和退出添加事件代码
分别双击弹出和退出(E),更改的代码如下
using System;
using System.Collections.Generic;
using System.componentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.windows.Forms;
namespace WindowsFormsHelloWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void 弹出ToolStripMenuItem_Click_1(object sender, EventArgs e)
{
messageBox.Show("我是“弹出”菜单");
}
private void 退出EToolStripMenuItem_Click_1(object sender, EventArgs e)
{
MessageBox.Show("我点击了“退出”菜单,确认后程序将关闭");
APPlication.Exit();
}
}
}
4. 运行结果