日期:2014-05-18 浏览次数:20821 次
public delegate void SendDataEventHandler(object sender,SendDataEventArgs e); public class SendDataEventArgs: EventArgs { private string data; public string SendedData { get { return data; } } public SendDataEventArgs(string data) { this.data = data; } } //定义一个公共的静态类 public static class FormEvent { public static event SendDataEventHandler SendData; public static void OnSendData(object sender, SendDataEventArgs e) { SendData(sender, e); } } //Form1中添加对事件的响应 FormEvent.SendData += new SendDataEventHandler(FormEvent_OnSendData); private void FormEvent_OnSendData(object sender,SendDataEventArgs e) { //处理你要做的事 } //Form2 //在要做事的时候引发事件 SendDataEventArgs ee = new SendDataEventArgs(str, true); FormEvent.OnSendData(this, ee);
------解决方案--------------------
对于窗体的交换,写过两篇文章建议参考,
Windows窗体间的数据交互
http://blog.csdn.net/zhzuo/archive/2004/04/05/22027.aspx
窗体的参数传递
http://blog.csdn.net/zhzuo/archive/2006/05/05/708941.aspx#sec5