Hi guys i am trying to catch the close event(press the X button) on a window form.
I try this
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// Display a MsgBox asking the user to save changes or abort.
if(MessageBox.Show("Do you want to save changes to your text?", "My Application",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// Cancel the Closing event from closing the form.
e.Cancel = true;
// Call method to save file...
}
}
But do nothing.
Any ideas??? What i am doing wrong