I am trying to close the app by clicking one button but it's not working.
this is my code.
private void buttonclose_Click(object sender, EventArgs e)
{
Application.Exit();
}
CodePudding user response:
Like @Dialecticus said, it could be that you never registered the event handler. In your form designer, when you double click the button it will register the click event for you automatically. If you didn't do that and your code was just copy/pasted you would have to go into the events to "wire" them yourself.
If that's not your issue, you could try using Environment.Exit()
or this.Close()
instead.
CodePudding user response:
Use this Code, it will diffidently work
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}