Me.Dispose和Me.Close的问题 [英] Problem with Me.Dispose and Me.Close

查看:234
本文介绍了Me.Dispose和Me.Close的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在某些形式下,我的代码有问题.例如,当我从frmOne调用frmTwo并想在显示frmTwo之前关闭frmOne时,它将无法工作.我用过代码

(在我写的frmOne中)

Hi,
In certain forms I am having problems with my code. For example when I call frmTwo from frmOne, and want to close frmOne before frmTwo is shown, it does not work. I used code

(In frmOne I wrote)

Me.Dispose
frmTwo.Showdialoge()



frmOne关闭,但不会出现frmTwo.

如果我不这样做的话,



frmOne closes but frmTwo does not appear.

If I do it otherwise,

frmTwo.Showdialoge()
Me.Dispose



在这种情况下,frmOne会一直在后台运行,这是我不希望的.
请告知如何管理.

谢谢和最诚挚的问候,
Furqan



In this case frmOne keeps running in the background, that I donot want.
Please advise how to manage it.

Thanks and best regards,
Furqan

推荐答案

我''并不确定,但是第二个代码片段看起来很有希望,因此请尝试如下操作:
I'' not quote sure, but the second code fragment looks promising so try it like this:
Me.Close()
frmTwo.Showdialog()



修改
Form.Showdialog()在模式模式下打开一个窗体.这意味着在关闭frmTwo之前,将不会执行该方法调用之后的代码!请参阅MSDN文档.
结束修改

除此之外,它不应该是Showdialog()末尾没有e并在方法调用中加上括号吗?

请告诉我这是怎么回事.

干杯!



Modification
Form.Showdialog() opens a form in modal mode. That means the code following the call of that method will not be executed until frmTwo is closed! See the MSDN documentation.
End modification

Besides that shouldn''t it be Showdialog() without an e at the end and parenthesis in the method calls?

Please tell me how this went.

Cheers!


我发现的窍门是

frmOne.Hide()
frmTwo.Showdialogue()
frmOne.Close()




只需致电frmTwo

frmTwo.Showdialogue()
并在其form_load事件中,关闭第一个表单

frmOne.Close()

这是我找到的唯一可行的方法.
The trick I found is

frmOne.Hide()
frmTwo.Showdialogue()
frmOne.Close()


Or

Just call frmTwo

frmTwo.Showdialogue()
and in its form_load event, close the first form

frmOne.Close()

This is the only workable way I found.


您不需要处理它,而是将其关闭

You don''t need to dispose it, but close it

frmTwo.Show()
Me.Close


这篇关于Me.Dispose和Me.Close的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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