c# winform 父窗口与子窗口的交互方法
作者:互联网
一、构造函数传入this对象
form1中:
private void Button1_Click(object sender, EventArgs e) { //通过构造函数传入当前窗口实例this new Form2(this).Show(); }
form2中:
Form mform1 = null; //先定义一个FORM1类,用来储存传过来的form1 public Form2(Form1 myform) { InitializeComponent(); mform = myform; }
form2使用:
private void button1_Click(object sender, EventArgs e) { mform.Hide(); mform.Show(); }
标签:myform,窗口,c#,mform,object,private,与子,void,构造函数 来源: https://www.cnblogs.com/yaoyue68/p/14624472.html