如何在窗体A中做操作,而窗体B能做出响应呢?
public partial class Form_A : Form
{
public Form_A()
{
InitializeComponent();
}
/// <summary>
/// 设置textbox的值
/// </summary>
public void SetValue(string _str)
{
this.textBox1.Text = _str;
}
private void button1_Click(object sender, EventArgs e)
{
FormB FB = new FormB(this);
FB.Show();
}
/// <summary>
/// 设置textbox的值
/// </summary>
public string GSTestBox
{
set
{
this.textBox1.Text = value;
}
}
}
public partial class FormB : Form
{
Form_A FA = new Form_A();//有一个Form_A的对象
public FormB()
{
InitializeComponent();
}
public FormB(Form_A _FA)
{
InitializeComponent();
FA = _FA;
}
private void button1_Click(object sender, EventArgs e)
{
FA.SetValue(this.textBox1.Text);//调用方法
FA.GSTestBox = "aaa";//设置属性
}
}