Small example of a prompt when c closes a form

  • 2020-05-17 06:16:37
  • OfStack


private void WorkflowConfigure_FormClosing(object sender, FormClosingEventArgs e)
        {

            DialogResult result = MessageBox.Show(" This action will discard your current Settings. Are you sure you want to continue? ", " exit ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (DialogResult.Yes == result)
            {
                e.Cancel = false;   // Cancel If the property is true Cancels the execution of the event. 
            }
            else
            {
                e.Cancel = true;
            }
        }


Related articles: