I have a little problem again but this time it regards the MessageBoxButton.YesNo. This is my problem: I don't know what's the right syntax so that if I hit Enter(keyboard) or click Yes, the Application.Exit(); will execute and if I hit Esc(keyboard) or  click No, the Application.Exit(); will not execute. This is my code:
MessageBox.Show("Are you sure you want to exit?","Application Exit", MessageBoxButtons.YesNo);
Application.Exit();
                You need to actually store off and check the result of the message box
var result = MessageBox.Show("Are you sure you want to exit?", "Application Exit", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
    Application.Exit();
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With