using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Demo0003
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 fr2 = new Form2();
//即便你不用实时监控但你也要知道你委托给谁去办事了吧
//他会带来你需要的信息 然后你该干吗就干吗
fr2.fangfa += fuzhi;
fr2.Show();
}
public void fuzhi(string str)
{
this.textBox1.Text = str;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Demo0003
{
public delegate void delegateclass(string str);
public partial class Form2 : Form
{
//哦明白了
public event delegateclass fangfa;
public Form2()
{
InitializeComponent();
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
string str = this.textBox1.Text;
Form1 f1 = new Form1();
//我变化啦
fangfa(str);
//多窗体间为多线程传递只能使用委托亲
}
}
}