I want to show a dialog (message box) before the actual form, and if user selects no, the application should completly be closed. I am trying to use the code below, but even after clicking on No the form will be shown!
public Form1()
{
InitializeComponent();
if (MessageBox.Show("Contiue or not", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1) == DialogResult.No)
Application.Exit();
}
I also tried this.Clsoe
but then I have an exepction on Application.Run()
What is the problem? Any idea what would be the best approach for doing so?