给你一些提示,你可以先尝试自己写写看:
假设Form1为启动主窗体,在Form1的Load事件中已经Show了一个Form2的窗体实例。其中Form2的构造函数应该已经被重载了一次(该重载函数应该包含Form1类型作为参数):
public partial class Form2
{
//省略其它生成代码……
//添加Form1类内部变量
private Form1 Form1{get;set;}
//自己添加新构造函数
public Form2(Form1 frm)
{
Form1 = frm;
Form1.MyEvent+=new Action(MyEventHandler);
}
………………
private void MyEventHandler()
{
//当Form1事件被触发的时候,Form2干啥就干啥……
}
}
同时不要忘记为Form1定义委托事件:
public event Action MyEvent = null;
然后在Form1的Button点击(或者类似事件),触发调用:
MyEvent();
If you think one reply solves your problem, please mark it as
An Answer, if you think someone's reply helps you, please mark it as a
Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats