Solved

Easiest Way to close a Window

Posted on 2006-06-15
5
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Amazon S3 .Net error 5 78
C# Formatting DateTime String Value 5 67
Adjust the codes 3 63
How do you think this website does searches? 5 34
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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