正确关闭应用程序 [英] Closing an application properly

查看:71
本文介绍了正确关闭应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个关闭程序来处理退出。按钮正确关闭

应用程序。如果用户

以另一种方式关闭它(通过按右上角的X为

实例或Alt +,我如何确保执行此操作4,等等)或者这是必要的吗?


-

谢谢,

Ricky W. Hunt
freendeed

I have written a close routine to handle an "Exit" button to close the
application properly. How do I make sure this gets executed if the user
closes it another way (by pressing the "X" in the upper right hand for
instance, or Alt+4, etc.) Or is this even necessary?

--
Thanks,
Ricky W. Hunt
freendeed

推荐答案

*" Ricky W. Hunt" < rh的***** @ hotmail.com> scripsit:
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
我写了一个关闭程序来处理退出。按钮正确关闭
应用程序。如果用户以另一种方式关闭它(通过按下右上角的X作为
实例,或Alt + 4等,我如何确保执行此操作)或者这是甚至是必要的?
I have written a close routine to handle an "Exit" button to close the
application properly. How do I make sure this gets executed if the user
closes it another way (by pressing the "X" in the upper right hand for
instance, or Alt+4, etc.) Or is this even necessary?




为表单''''Closing''事件添加一个处理程序来处理表单的结束

过程。您可以将''e.Cancel''设置为''False''取消

关闭表格。


-

Herfried K. Wagner [MVP]

< URL:http://dotnet.mvps.org/>

< URL:http:// dotnet.mvps.org/dotnet/faqs/>



Add a handler to your form''s ''Closing'' event to handle the closing
process of a form. You can set ''e.Cancel'' to ''False'' there to cancel
closing the form.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>


" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:ue ************** @ TK2MSFTNGP11.phx.gbl ...
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ue**************@TK2MSFTNGP11.phx.gbl...
*" Ricky W 狩猎 < rh的***** @ hotmail.com> scripsit:
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
我写了一个关闭程序来处理退出。按钮正确关闭
应用程序。如果用户以另一种方式关闭它(通过按下右上角的X作为
实例,或Alt + 4等,我如何确保执行此操作)或者这是甚至是必要的?
为表单''''Closing''事件添加一个处理程序来处理表单的关闭过程。
I have written a close routine to handle an "Exit" button to close the
application properly. How do I make sure this gets executed if the user
closes it another way (by pressing the "X" in the upper right hand for
instance, or Alt+4, etc.) Or is this even necessary?
Add a handler to your form''s ''Closing'' event to handle the closing
process of a form.




因此无论程序是如何关闭,程序总是会运行此事件吗?意思是,我可以把我的所有包装代码放在Closing事件中吗

甚至让它按下Exit按钮处理某人?

你可以设置''e.Cancel '''''False''有取消
关闭表格。



So will the program always run this event regardless of how a program is
closed? Meaning, could I just put all of my wrapup code in the Closing event
and even let it handle someone pressing the Exit button?
You can set ''e.Cancel'' to ''False'' there to cancel
closing the form.




我不知道这意味着什么。我知道如何禁用X在表格

上使用设计视图中的属性。我希望他们能够用X关闭

程序,我只是想确保它运行我的包装代码。



I''m not sure what that means. I know how to disable the "X" on the form
using the properties in design view. I want them to be able to close the
program with the X, I just want to make sure it runs my wrapup code.


什么Herfried说,如果由于某种原因你在代码中决定表格不应该接近,即使他们按下了X。 (例如,你需要它们来保存他们的数据),然后你可以将e.Cancel属性设置为False并且表单不会关闭。


HTH

-

David Williams,VB.NET MVP

" Ricky W. Hunt"写道:
What Herfried is saying is that if for some reason you decide in your code that the form should not be close, even though they pressed the "X" (for instance, you need them to save their data), then you can set the e.Cancel property to False and the form will not close.

HTH
--
David Williams, VB.NET MVP
"Ricky W. Hunt" wrote:
" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道
新闻:ue ************** @ TK2MSFTNGP11.phx.gbl ...
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ue**************@TK2MSFTNGP11.phx.gbl...
*" Ricky W. Hunt" < rh的***** @ hotmail.com> scripsit:
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
我写了一个关闭程序来处理退出。按钮正确关闭
应用程序。如果用户以另一种方式关闭它(通过按下右上角的X作为
实例,或Alt + 4等,我如何确保执行此操作)或者这是甚至是必要的?
I have written a close routine to handle an "Exit" button to close the
application properly. How do I make sure this gets executed if the user
closes it another way (by pressing the "X" in the upper right hand for
instance, or Alt+4, etc.) Or is this even necessary?



为表单''''Closing''事件添加一个处理程序来处理表单的关闭过程。



Add a handler to your form''s ''Closing'' event to handle the closing
process of a form.


无论程序如何关闭,程序总是运行此事件?意思是,我可以把我的所有包装代码放在Closing事件中吗?甚至让它按下Exit按钮处理某人?



So will the program always run this event regardless of how a program is
closed? Meaning, could I just put all of my wrapup code in the Closing event
and even let it handle someone pressing the Exit button?

你可以设置''e.Cancel '''''False''有取消
关闭表格。
You can set ''e.Cancel'' to ''False'' there to cancel
closing the form.



我不知道这意味着什么。我知道如何禁用X在表格上使用设计视图中的属性。我希望他们能够用X关闭
程序,我只是想确保它运行我的包装代码。



I''m not sure what that means. I know how to disable the "X" on the form
using the properties in design view. I want them to be able to close the
program with the X, I just want to make sure it runs my wrapup code.



这篇关于正确关闭应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆