Beispiel #1
0
        //user wants to exit - confirm before unloading
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to exit?", "Confirm Exit",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                //user changed their minds
                return;
            }

            //exit application
            GlobalItems.FinalExit();
        }
Beispiel #2
0
        //if the user closed the form without logging in using the OK button, exit the application.
        private void FormLogin_FormClosing(object sender, FormClosingEventArgs e)
        {
            //the the user hit OK the dialog is closing but the result will be set to "OK" so make sure to account
            //for that here.
            if (this.DialogResult != DialogResult.OK)
            {
                //for this sample applicaiton canceling the login is the same as exiting the application.
                if (MessageBox.Show("Are you sure you want to abort the login?  This will exit the application.", "Cancel login",
                                    MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    //user changed their mind - cancel out and return.
                    e.Cancel = true;
                    return;
                }

                //exit the application
                GlobalItems.FinalExit();
            }
        }