You need to handle Form1's FormClosing event (add the skeleton handler from the Properties Box):
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { DialogResult dr = MessageBox.Show("Are you sure you want to quit the application?", "Confirmation required", MessageBoxButtons.YesNo); if (dr == DialogResult.No) e.Cancel = true; }
If the user clicks the 'No' button, the closure of the form (and hence the application) will be cancelled.
1 answers
You need to handle Form1's FormClosing event (add the skeleton handler from the Properties Box):
If the user clicks the 'No' button, the closure of the form (and hence the application) will be cancelled.
answered 2 years ago by:
17279
153
thank you for the good answer