Handling Cancel on Form Close

  • Thread starter Thread starter bg_ie
  • Start date Start date
B

bg_ie

Hi,

I have an event handler to handle the closing of a form. In this
handler (Form1_FormClosing), I ask the user if they wish to save
updates made to a file. I wish to add the option to the message box to
allow the user to cancel so that the form doesn't actually close. This
is the behaviour you would see if you closed a word document - Save
changes to X.doc - Yes,No,Cancel.

Thanks for your help,

Barry.
 
Something like... (watch for wrap)

switch (MessageBox.Show(this, "Blah blah blah", "Save
changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button3)) {
case DialogResult.Yes:
// do the save
break;
case DialogResult.No:
// wave goodbye
break;
default:
e.Cancel = true;
break;
}

?

Marc
 
Back
Top