string msg= "Do you want to close the application?";
string caption = "Confirm...";
if ( MessageBox.Show( msg, caption, MessageBoxButtons.YesNo )
== DialogResult.No )
e.Cancel = true;
Displaying a confirmation dialog box when the user closes the form.
You should use the FormClosing event to show a dialog box.


Join the conversation! Your thoughts help the community grow.