how to address the situation of closing the form
-
when the user try to close the form by clicking the close button of the title bar.how can show a dialog box to verify the form closing ?
-
when the user try to close the form by clicking the close button of the title bar.how can show a dialog box to verify the form closing ?
you will get form closing event @ that time
My small attempt...
-
you will get form closing event @ that time
My small attempt...
in witch event ? the closed or closing event ?
-
in witch event ? the closed or closing event ?
Its on your form closing event, you need to add code to cancel/continue..I presume something like the following.
private void FormClosing(object sender, CancelEventArgs e) { if (MessageBox.Show("Are you sure you want to exit?", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { e.Cancel = true; } }
A craft is an enemy if not well learned.
-
Its on your form closing event, you need to add code to cancel/continue..I presume something like the following.
private void FormClosing(object sender, CancelEventArgs e) { if (MessageBox.Show("Are you sure you want to exit?", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { e.Cancel = true; } }
A craft is an enemy if not well learned.
thanks
-
in witch event ? the closed or closing event ?
Why don't you try it yourself? Or have a look at documentation? There is no chance of canceling the process if one of the events has already been fired. (Guess which one it is)
#region signature my articles #endregion