日期:2014-05-17 浏览次数:21101 次
//form1:
public partial class Form1 : Form
{
public delegate void MyDel(string value);
public event MyDel txtzt;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(this);//this这里说的是指针,伏笔
f2.Show();
}
}
//form2
public partial class Form2 : Form
{
public Form2(Form1 f1)//Form1吗?你确定不是Form1*吗?刚才明明给的是指针呀
{
InitializeComponent();
f1.txtzt += new Form1.MyDel(txtzt);
}
private void txtzt(string s)
{
this.textBox1.Text = s;
}
}