[轉]C#WinForm應用程式——新增選單欄MenuStrip
阿新 • • 發佈:2019-01-03
【C#WinForm應用程式——新增選單欄MenuStrip】
2018年08月09日 10:53:07 鹹魚不會游泳 閱讀數:1360
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. 執行結果
新增狀態列和工具欄可以舉一反三類似這樣的操作