Easiest Way to close a Window

I have a window, that has a close button, I would like to make it close. So I have the method:

    private void m_CloseButton_Click(object sender, System.EventArgs e)
    {
      components.Dispose();
    }

is Components.Dispose();

The easiest way or is there another way?
directxBOBAsked:
Who is Participating?
 
jvn222Commented:
try this.Close();
0
 
tsayCommented:
You can use two methods. You should use the close method on the current form object. To call this, just type this.close(); The close method will displose all resources used by the form.

You can also use Application.Exit(); but in that case the form_Close and form_Closing events are NOT triggered so be carefull with this as code won't be executed in these events.

hth
0
 
pradeepsudharsanCommented:
this.Dispose();
--pradeep
0
 
pradeepsudharsanCommented:
Hi tyr this
using System.Threading;

and add
Thread.CurrentThread.Abort();

--pradeep
0
 
vo1dCommented:
what do you wanna close? only a specific form or the whole application with different forms?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.