111,125
社区成员
发帖
与我相关
我的任务
分享
//在Form3.cs中添加一个构造函数
public Form3(ref CheckBox cb) { cb.Text = "Yeah";//我用的是CheckBox,而不是textBox }
//然后在Form2.cs的Button1_Click事件中添加://实例化Form3
Form3 fr = new Form3(ref checkBox1); fr.Show();
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(this);
f2.Show(this);
}
}
}
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
Form1 f;
public Form2(Form1 _f)
{
f = _f;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
f.textBox1.Text = this.textBox1.Text;
}
}
}