B Rawlings

B Rawlings

  • NA
  • 6
  • 3.6k

FormClosing event not working

May 28 2014 3:33 PM

I would like to get a response from the user when X is selected to close the child form but instead the formclosing event just closes the form

Can anyone help? This is my code below: 


private void Form2_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult responseDialogResult;

            if (isDirtyBoolean)
            {
                responseDialogResult = MessageBox.Show(
                    "The data on the form has changed. Do you want to save the contents of the form to a file?", "File Change",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (responseDialogResult == DialogResult.Yes)
                {
                    saveToolStripMenuItem_Click(sender, new System.EventArgs());
                }


Answers (1)