Solved

Easiest Way to close a Window

Posted on 2006-06-15
5
218 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is Thread.Sleep? 5 46
ADO.NET ENTITY DATA MODEL 3 32
C# Offline Apllication 5 55
Best resource to learn entity framework 2 8
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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

896 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

20 Experts available now in Live!

Get 1:1 Help Now