End application

G

Guest

Hi,

I would like to be able to end my application when pushing a button. Like
the X in the upper right corner. How is this done. How do I send end app
event?

regards Jesper.
 
Z

zacks

Hi,

I would like to be able to end my application when pushing a button. Like
the X in the upper right corner. How is this done. How do I send end app
event?

regards Jesper.

Depends. Assuming you are asking about a standard Windows Application
project. If the current code path is the main form, then just create a
command button control and in the Click event handler just do a:

this.Close();

If you are in a child form or dialog window, you will need to send
this information back to the main form. Closing the main form shuts
down the app.
 
N

Nicholas Paldino [.NET/C# MVP]

Or, you can just call the static Exit method on the Application class,
which will send a WM_QUIT message to the main window and cause it to shut
down. This can be done from anywhere.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Jesper said:
Hi,

I would like to be able to end my application when pushing a button. Like
the X in the upper right corner. How is this done. How do I send end app
event?

The Applicacion class has a method that let you do it.
Application.Exit will do it
 
G

Guest

Hej Jesper

Make a button Form1 object and write this.Close(); were "this" this is Form1
object
If I have read the questen right its work. .NET will activate the cloce
procidure for X in upper right corner

Regards

Kim S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top