如何从C#中的另一种形式调用事件 [英] How to call event from another form in C#

查看:84
本文介绍了如何从C#中的另一种形式调用事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有按钮A1的表格A和带有按钮B1的表格B.
单击按钮A1时,显示对话框B,单击按钮B1时,调用事件A1的form_load事件.

请帮助我

I have form A with button A1 and form B with button B1.
when click on button A1, show dialog form B and when click on button B1, call event form_load of form A1.

please help me
thanks.

推荐答案

您不能直接从外部引发Load事件.显示表单时(通过ShowShowDialog),将自动引发此事件.

如果要显示按钮处理程序中的新表单,只需实例化该表单并在按钮处理程序中调用其ShowShowDialog方法.

如果您想做其他事情,请提供更多详细信息.
You can''t directly raise the Load event from outside. This event is raised automatically when the form is shown (through Show or ShowDialog).

If you want to display a new form from a button handler, just instanciate that form and call its Show or ShowDialog method inside the button handler.

If you want to do something else, then please give more details.


您应该研究此链接
You should study this link Opening form instances in C#

Best Regard,
Theingi Win


this[^] might help you.


这篇关于如何从C#中的另一种形式调用事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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