功能说明:如图
子窗体和母窗体的文本框相互传值
ParentForm.cs:
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class ParentForm : Form
{
public ParentForm()
{
InitializeComponent();
}
private void parentButton_Click(object sender, EventArgs e)
{
ChildForm childForm = new ChildForm(this);
childForm.ChildTextBox.Text = this.parentTextBox.Text;
childForm.ShowDialog();
//也可以在这里子窗口关闭后给父窗口的文本框赋值
//if (childForm.DialogResult == DialogResult.OK)
//{
// this.parentTextBox.Text = childForm.Text;
//}
}
public TextBox ParentTextBox
{
set { this.parentTextBox = value; }
get { return this.parentTextBox; }
}
}
}