0

Hello! I'm writing a text editor in C# and I have it so when the user is to close the program and the open document has been edited it prompts the user with a DialogBox asking them to save. Here is the code:

protected override void OnFormClosing(FormClosingEventArgs e)
        {
                if (e.CloseReason == CloseReason.WindowsShutDown) return;
                if (changed == true)
                {
                    DialogResult savePrompt = MessageBox.Show("Would you like to save your doument?","Save this document?",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question);
                    if(savePrompt == DialogResult.Yes){
                        save();
                    }
                    else if (savePrompt == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                }
                else
                {

                }
        }

Now the problem is when I select Yes to save it doesn't fire off the save() method I wrote. Any ideas? Thanks for any help!

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by Mike Askew
0

Have you checked to see the code enters the if statements correctly down the save method call?

Edited by Mike Askew

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.