Solved

Easiest Way to close a Window

Posted on 2006-06-15
5
217 Views
Last Modified: 2010-04-16
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?
0
Comment
Question by:directxBOB
5 Comments
 
LVL 4

Accepted Solution

by:
jvn222 earned 500 total points
ID: 16909468
try this.Close();
0
 
LVL 5

Expert Comment

by:tsay
ID: 16909500
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
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16909797
this.Dispose();
--pradeep
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16909912
Hi tyr this
using System.Threading;

and add
Thread.CurrentThread.Abort();

--pradeep
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16911812
what do you wanna close? only a specific form or the whole application with different forms?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Bubble user-defined Sql RAISERROR(...) to c# exception 14 117
Expando 4 34
Image(7) 1 37
getting id from database 5 24
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now