应用事件说明:
Form2中某个数值发生改变时,要改变Form1中的值。
Form2中应该加的代码:
public delegate void change(string strTxt);
public event change onchange;
private void Test( string strTxt)
{
if (onchange != null)
{
onchange( strTxt );
}
}
Form1中的代码:
form2.onchange += new Form2.change( this.changetext);
private void changetext ( string strTxt )
{
this.textBox1.Text =strTxt;
}
Form2中某个数值发生改变时,要改变Form1中的值。
Form2中应该加的代码:
public delegate void change(string strTxt);
public event change onchange;
private void Test( string strTxt)
{
if (onchange != null)
{
onchange( strTxt );
}
}
Form1中的代码:
form2.onchange += new Form2.change( this.changetext);
private void changetext ( string strTxt )
{
this.textBox1.Text =strTxt;
}