c# 一个窗口点击另外一个窗口触发事件
1个回答
展开全部
参考
form1上代码
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Owner = this;
f2.ShowDialog();
}
public void test(string txt)
{
textBox1.Text = txt;
}
form2上代码
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = (Form1)this.Owner;
f1.test(textBox1.Text);
this.Close();
}
form1上代码
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Owner = this;
f2.ShowDialog();
}
public void test(string txt)
{
textBox1.Text = txt;
}
form2上代码
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = (Form1)this.Owner;
f1.test(textBox1.Text);
this.Close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询