我的水平实在是太菜,看了半天也没看出个所以然
我是form1把form2显示出来,form2再设置form1上控件的属性
现在还是晕糊中
本人原本是硬件开发之徒,因为是计算机专业所以业余时间玩玩,现在全力突击c#
我在ytyt654的基础上再改一下了
public class MsgEventArgs:System.EventArgs//必须从这个类继承
{
public string textMsg;
public MsgEventArgs()
{}
}
public delegate void MyHandler(object sender,MsgEventArgs e);
public class Form2 : System.Windows.Forms.Form
{
public event MyHandler MyEvent;
private void button1_Click(object sender, System.EventArgs e)
{
if (MyEvent != null)
{
MsgEventArgs ea=new MsgEventArgs ();
ea.textMsg=this.textBox1.Text; //假设From2上有个textBox1
MyEvent(this,ea);
}
}
}
public class Form1 : System.Windows.Forms.Form
{
private void button1_Click(object sender, System.EventArgs e)
{
Form2 form2 = new Form2();
form2.MyEvent += new MyHandler(form2_MyEvent);
form2.Show();
}
private void form2_MyEvent(object sender,MsgEventArgs e)
{
//statusBar1.Text = "Form2 Button Clicked!";
statusBar1.Text = e.textMsg;
}
}
这样就把From2中TextBox的属性带回来了