如何知道表格已关闭 [英] How to know a form is closed

查看:74
本文介绍了如何知道表格已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我声明了一个myForm类型的变量X然后实例化myForm,在变量X中保存一个

引用,然后执行X.Show。


如果我需要知道表单是否已经显示,我检查X对Nothing。


如果用户关闭MyForm,我希望X设置为Nothing but don''知道

如何感知(MyForm除外)myForm正在关闭。


在myForm的Closing事件中,如果我设置Me = Nothing will将X设置为

什么都没有?


在封闭事件中这样做怎么样?

I declare a variable X of type myForm then instantiate myForm saving a
reference in the variable X, and then do X.Show.

If I need to know if the form has been shown yet, I check X against Nothing.

If the users closes MyForm I''d like X to be set to Nothing but don''t know
how to sense (except in MyForm) that myForm is closing.

In the myForm''s Closing event if I set Me=Nothing will that set X to
Nothing?

How about doing it in the Closed event?

推荐答案

嗨Sam,


您使用的是VB.net


将表单设置为空是不正常的。

VB.net是托管代码,设置为零是你正常管理的东西之一。


Cor
Hi Sam,

Are you using VB.net

There it is not normal to set your forms to nothing.
VB.net is managed code, setting to nothing is one of the things that is
normaly managed for you.

Cor


" SamSpade" < ST ************** @ REMOVEaol.com>在消息新闻中写道:< #t ************** @ TK2MSFTNGP11.phx.gbl> ...
" SamSpade" <st**************@REMOVEaol.com> wrote in message news:<#t**************@TK2MSFTNGP11.phx.gbl>...
我声明了一个类型为myForm的变量X实例化myForm在变量X中保存一个
引用,然后执行X.Show。

如果我需要知道表单是否已经显示,我会检查X对Nothing。


这并不告诉你表格已经显示,它告诉你表格

已被实例化。


如果用户关闭MyForm,我希望X设置为Nothing但不知道如何感知(除了在MyForm中)myForm正在关闭。
在myForm'的Closing事件中,如果我设置Me =没有什么会将X设置为
Nothing?
I declare a variable X of type myForm then instantiate myForm saving a
reference in the variable X, and then do X.Show.

If I need to know if the form has been shown yet, I check X against Nothing.
This doesn''t tell you the form has been shown, it tells you the form
has been instantiated.

If the users closes MyForm I''d like X to be set to Nothing but don''t know
how to sense (except in MyForm) that myForm is closing.

In the myForm''s Closing event if I set Me=Nothing will that set X to
Nothing?




你不必这样做,如果表格是一种常规形式。作为常规的

形式,这是自动完成的。关闭事件发生时,表格

正在关闭。关闭表单后,将释放在对象内创建的所有资源,并释放表单。


如果您创建表单作为对话框表单,即.ShowDialog而不是

..然后你应该看看DialogResult属性并注意

上述规则不适用。对于对话框表单,资源不会自动发布。


无论哪种方式都可以阅读有关OnClosing,OnClosed和

DialogResult事件的文档和物业。

Hth


Richard



You dont have to do this if the form is a regular form. As regular
form this is done automatically. The Closing event occurs as the form
is being closed. When a form is closed, all resources created within
the object are released and the form is disposed.

If you create a form as a dialog form i.e .ShowDialog rather than
..Show then you should check out the DialogResult property and note
that the above rule does not apply. Resources are not automaticlly
released for dialog forms.

Either way read the docs about the OnClosing, OnClosed and
DialogResult events and properties.
Hth

Richard


*" SamSpade" < ST ************** @ REMOVEaol.com> scripsit:
* " SamSpade" <st**************@REMOVEaol.com> scripsit:
我声明一个myForm类型的变量X然后实例化myForm,在变量X中保存一个
引用,然后执行X.Show。

如果我需要知道表单是否已经显示,我检查X对Nothing。

如果用户关闭MyForm我希望X设置为Nothing但不知道
如何感知(MyForm除外)myForm正在关闭。

在myForm的Closing事件中,如果我设置Me = Nothing将X设置为
Nothing?
在封闭活动中如何做?
I declare a variable X of type myForm then instantiate myForm saving a
reference in the variable X, and then do X.Show.

If I need to know if the form has been shown yet, I check X against Nothing.

If the users closes MyForm I''d like X to be set to Nothing but don''t know
how to sense (except in MyForm) that myForm is closing.

In the myForm''s Closing event if I set Me=Nothing will that set X to
Nothing?

How about doing it in the Closed event?




< http://groups.google.de/groups?selm = eZIYbXOEDHA.2892% 40TK2MSFTNGP11.phx.gb l>


-

Herfried K. Wagner [MVP]

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

网站地址已更改!



<http://groups.google.de/groups?selm=eZIYbXOEDHA.2892%40TK2MSFTNGP11.phx.gb l>

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!


这篇关于如何知道表格已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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