菜单和菜单组件
- 添加菜单
- 编辑菜单
添加菜单
将MenuStrip控件拖拽到Form窗体顶部添加菜单
编辑菜单
添加菜单项,编辑菜单属性等功能。
右键单击已添加的菜单项可以弹出右键菜单:
可以设置菜单图标,使能菜单,显示快捷键、转换菜单项类型、插入菜单项、编辑子菜单等操作。
Form1.cs
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 菜单和菜单组件
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void toolStripMenuItem4_Click(object sender, EventArgs e){MessageBox.Show("新建","操作提示");}private void toolStripMenuItem5_Click(object sender, EventArgs e){MessageBox.Show("打开", "操作提示");}private void toolStripMenuItem6_Click(object sender, EventArgs e){MessageBox.Show("保存","操作提示");}private void toolStripMenuItem7_Click(object sender, EventArgs e){MessageBox.Show("关闭", "操作提示");}private void toolStripMenuItem8_Click(object sender, EventArgs e){MessageBox.Show("撤销", "操作提示");}}
}