有关呼叫事件的问题 [英] Question regarding Calling event

查看:69
本文介绍了有关呼叫事件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#.net桌面应用程序中有两个表单,现在我想点击第一个表单上的按钮调用第二页加载事件,以便我怎么做?

请帮帮我??

i have two forms in c#.net desktop application and now i want to call the second page load event on click of the button which is present on the first form so how i will do it?
please help me??

推荐答案

protected void Button1_Click(object sender, eventargs e)
{
SecondForm obj=new SecondForm();
obj.Show();
obj.Page_Load();
}





创建第二种形式的对象并调用第二种形式的方法......



-anurag



create an object of the second form and call the methods of the second form...

-anurag


您无法在Windows窗体的代码中直接调用'Load EventHandler。



当您在Form的实例上调用'Show()...或'ShowDialog()时:所有已定义的'正在显示的Form的Load EventHandlers会自动调用。是的,我说:所有:你可以为'加载定义了几个EventHandler,尽管我建议你不要在'Load EventHandler'的情况下这样做。



如果您尝试直接从代码调用'加载事件',您将收到如下错误消息:事件'System.Windows.Forms.Form.Load'只能出现在+ =或 - =
You cannot directly invoke the 'Load EventHandler in code in Windows Forms.

When you call 'Show() ... or 'ShowDialog() on an instance of a Form: all defined 'Load EventHandlers of the Form being shown are called automatically. Yes, I said: "all:" you could have several EventHandlers defined for 'Load, although I recommend you don't do this in the case of the 'Load EventHandler.

If you try and call the 'Load Event directly from code, you'll get an error message like this: "The event 'System.Windows.Forms.Form.Load' can only appear on the left hand side of += or -="


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

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