在C#中如何实现Form与Form之间的通信

 

实现方法如下:

1. 从Form 继承一个 Form1类.

2. 从Form 继承一个 Form2类.

3.在Form2类中加一个成员变量:frmParent

4.在Form2 类中加入一个重载的构造方法:public form2(Form1 Parent){frmParent=Parent};

5.在Form1中添加一个Button对象. 对应的事件代码为:

{

       Form2 frm=new Form2(this);
       frm.Show();
  

}

6.在Form2中添一个Button对象,对应事件代码为:

{

frmParent.Text="成败改写";

posted @ 2007-03-31 00:45  looky  阅读(1133)  评论(2编辑  收藏  举报