I'm doing an app in c# and I'm having a little problem while trying to close my app.
So, when my app starts, there's a message box that appears on the load. Then I have 3 options, yes no and cancel.
I'd like that, if the user click on the exit button of that messageBox, that it closes the whole app. But instead, it just closes the message box and shows the next of my app.
I've tried things like Environment.Exit(0); Application.Exit... but nothing worked
Here's my code !
private void Form1_Load(object sender, EventArgs e)
{
//this is executed on the load of my form, the user has to choose a difficulty that will change the depth
// IMPORTANT :
//Facile stands for Yes
//Moyen stands for No
//Difficile stands for Cancel
MessageBoxManager.Yes = "Facile";
MessageBoxManager.No = "Moyen";
MessageBoxManager.Cancel = "Difficile";
MessageBoxManager.Register();
DialogResult result = MessageBox.Show("Quelle est la difficulté?", "Niveau de jeu",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
//according to the chosen button, the value of depth will change
if (result == DialogResult.Yes) // facile
{
profondeur = 3;
}
else if (result == DialogResult.No)
{
profondeur =6 ;
}
else if (result == DialogResult.Cancel)
{
profondeur = 9;
}
else {
Environment.Exit(0); //if any other button is clicked ?
}
}
Thank you in advance !