使用ShowDialog不会触发Load事件 [英] Load event do not fires with ShowDialog
本文介绍了使用ShowDialog不会触发Load事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Windows窗体上的Load事件遇到问题,当从ShowDialog()
调用它时不会触发它:
Hi,
I am having problem with the Load event on a windows form that does not get fired when it is called from ShowDialog()
:
Form1 myForm = new Form1();
myForm.ShowDialog();
我已经上网,但是还没有找到任何解决方案.我发现此 [ ^ ],但这不是我的情况,因为我没有使用任何 ActiveX .
我也尝试使用Show()
,但没有结果.
请帮忙!
谢谢.
I had gone through the internet but have not find any solution yet. I have found this[^], but this is not my case since I do not use any ActiveX.
I have also tried to use Show()
with no result.
Please help!
Thanks.
推荐答案
我敢打赌,它会在您首次显示ShowDialog时触发,但不会在随后的调用中触发.我相信您需要在完成后调用myForm.Dispose();
.
I''ll bet it fires the first time you ShowDialog but not subsequent calls. I believe you need to call myForm.Dispose();
when done.
对我来说很好-您确定已将事件链接到其中吗?
如果绝对确定,并且该方法出现在窗体的事件列表中,请进行干净的重建,然后关闭并在VS上重新启动.
It works fine for me - are you sure you have linked the event in?
If you are absolutely certain, and the method appears in the events list for your form, then do a clean rebuild, followed by a close and restart on VS.
您要调用InitializeComponent()
在所有重载的构造函数中?
Are you calling InitializeComponent()
in all of your overloaded constructors?
这篇关于使用ShowDialog不会触发Load事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文