Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Easiest Way to close a Window

Posted on 2006-06-15
5
Medium Priority
?
226 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 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