读书人

兑现子窗口到主窗口的传值

发布时间: 2012-12-18 12:43:41 作者: rapoo

实现子窗口到主窗口的传值

在子窗口的两个textbox输入字符串后,他们的内容将会显示在主窗口的textbox上。


子窗口的控件:两个textbox,两个button

子窗口:

?

?

namespace sign_in{    public partial class MainForm : Form    {        private string f_no;        private string f_name;        public string f_No        {            get            {                return this.f_no;            }            set            {                this.f_no = value;            }        }        public string f_Name        {            get            {                return this.f_name;            }            set            {                this.f_name = value;            }        }        public MainForm()        {            InitializeComponent();                    }       private void button1_Click(object sender, EventArgs e)        {            Child child = new Child();            if (child.ShowDialog() == DialogResult.OK)            {                this.textBox1.Text = child.c_No;                this.textBox2.Text = child.c_Name;            }        }    }}
?

?

?

读书人网 >编程

热点推荐