So I have a text editor I'm working on. One of the things I need to add is where when you close the program, if one or more of your files aren't saved, it will ask you if you want to save them before closing, and it gives you the options "Save", "Don't Save", or "Cancel", the last telling the application that "sorry, I didn't mean to close".
Is there a tutorial or something that I could read to learn how to do this

Save Before Exit?
user11
Before you close your form, you can use the Form.FormClosing event. This way, if you click on the X in the upper-right or you your menu exit, it will still throw this event. Here is a quick event handler that I wrote to illustrate how to keep the application from closing.
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (richTextBox1.Rtf != initialRtfString)
{
switch (MessageBox.Show("Do you want to save ", "Save File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation))
{
case DialogResult.Yes:
SaveFile();
e.Cancel = false;
break;
case DialogResult.No:
e.Cancel = false;
break;
case DialogResult.Cancel:
e.Cancel = true;
break;
}
}
}
The MessageBox will show you those options that you requested.