父窗口:
子窗口:
点击“Form1”对话框上的“Form2”按钮后弹出“Form2”对话框,在输入框中输入“1111111”,关闭对话框“Form2”时将值赋给“Form1”上的输入框中。
实现代码如下:
public partial class Form1 : Form
{
public void SetValue(string sStr)
{
textBoxX1.Text = sStr;
}
private void node3_NodeClick(object sender, EventArgs e)
{
Form2 tmpForm = new Form2();
tmpForm.Owner = this;
tmpForm.Show();
}
}
/////////////////////////////////////////////////////////////////////
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
Form1 tmp = (Form1)this.Owner;
tmp.SetValue(textBoxX1.Text);
}
原文:http://my.oschina.net/871120/blog/512799