c# 子窗体向父窗体传值

来源:互联网 发布:机甲mesuit 知乎 编辑:程序博客网 时间:2024/05/21 09:47

//父类代码

Form2 frm2 = new Form2();
frm2.Owner = this;
frm2.Show();
//或 frm2.Show(this);
//或 frm2.ShowDialog(this);


//子类代码

Form1 frm1 = (Form1)this.Owner;
frm1.textBox1.Text = "aaa";


子窗体关闭时调用父窗体方法:

//父类代码

//将子窗口关闭时触发父类aaa方法

Form2.ActiveForm.FormClosed += new System.Windows.Forms.FormClosingEventHandler(this.aaa);

原创粉丝点击