为什么要为此使用反射?
创建第二个表单时,只需传入对第一个表单的引用:
// I assume it's code within Form1 which opens Form2
Form2 form2 = new Form2(this);
form2.Show();
Run Code Online (Sandbox Code Playgroud)
假设您很乐意添加构造函数Form2
作为参数.或者,将其作为以下属性Form2
:
Form2 form2 = new Form2 { Form1 = this };
form2.Show();
Run Code Online (Sandbox Code Playgroud)