//定義一個需要string類型參數的委托
publicdelegate void MyDelegate(string text);
public partial class Form2 :Form1
{
//定義該委托的事件
public event MyDelegate MyEvent;
public Form2(string text)
{
InitializeComponent();
this.textBox1.Text = text;
}
private void btnChange_Click(object sender, EventArgs e)
{
//觸發事件,并將修改后的文本回傳
MyEvent(this.textBox1.Text);
this.Close();
}
}