public delegate void MyMessage(int argIn);
public event MyMessage Message;
Form2
//触发事件
Message(o);
Form1中:
Form2 form2 = new Form2();
form2.Message+=new MyMessage(OnXmlChanged)

解决方案 »

  1.   

    没人响应嘛
    this.message(0)调试不过!
      

  2.   

    //声明为消息
    public delegate void MyMessage(int argIn);放在类外部,命名空间中,//Form1
    private void button1_Click(object sender, System.EventArgs e)
    {
    Form2 fm = new Form2();
    fm.MyEvent += new MyCallBack(Test);
    fm.Show();
    }
    private void Test(int message)
    {
    MessageBox.Show(message.ToString());
    }
    //Form2
    namespace TDoubleFrom
    {
    //*在命名空间内申明*
    public delegate void MyCallBack(int n ); 
    /// <summary>
    /// Form2 的摘要说明。
    /// </summary>
    public class Form2 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Button button2; public event MyCallBack MyEvent; //申明事件 /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form2()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    }
    private void button2_Click(object sender, System.EventArgs e)
    {
    if(MyEvent != null)
    MyEvent(2);
    }
    }
    }