日期:2014-05-17 浏览次数:20775 次
public delegate void WarnDelegate(); public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void Alarm() { //刷新Grid } private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); f2.WarnEvent += new WarnDelegate(Alarm); } } public partial class Form2 : Form { public event WarnDelegate WarnEvent; public Form2() { InitializeComponent(); } public void OnWarnEvent() { if (WarnEvent != null) { WarnEvent(); } } public void Warn() { OnWarnEvent(e); } private void button1_Click(object sender, EventArgs e)//点击它就会执行Form1中的Alarm来刷新Grid { Warn(); } }