namespace Menu { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { ContextMenuStrip.Items.Add(exitToolStripMenuItem1); } private void ToolStripMenuItem1_Click(object sender, EventArgs e) { ToolStripMenuItem itmCurrent = (ToolStripMenuItem)sender; switch (itmCurrent.Name) { case "exitToolStripMenuItem1": System.Windows.Forms.DialogResult interactionResult; interactionResult = MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (interactionResult == System.Windows.Forms.DialogResult.Yes) Application.Exit(); break; } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)