Close Form Button Event

前端 未结 6 1986
暗喜
暗喜 2021-02-03 15:11

in my application, the user is first presented with the log in screen, and the form that shows up after you log in has a Menu Bar. On that menu bar are 2 items: \"log out\" and

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-03 15:35

    private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (MessageBox.Show("This will close down the whole application. Confirm?", "Close Application", MessageBoxButtons.YesNo) == DialogResult.Yes)
        {
            MessageBox.Show("The application has been closed successfully.", "Application Closed!", MessageBoxButtons.OK);
            System.Windows.Forms.Application.Exit();
        }
        else
        {
            this.Activate();
        }  
    }
    

提交回复
热议问题