[英]How to change controllers visibility from another WinForm C#
I have 2 WinForm in Form1 i have Panel and i load Form2 inside Panel(in Form1)我在 Form1 中有 2 个 WinForm 我有 Panel 并且我在 Panel 中加载了 Form2(在 Form1 中)
My code for open From2 inside Panel1我在 Panel1 中打开 From2 的代码
Form2 f = new Form2(); f.TopLevel = false; panel1.Controls.Add(f); f.Show();
In Form2 i have button for close the Form and hide the Panel , i can close the Form2 but i can't hide the Panel1在 Form2 中,我有关闭 Form 和隐藏 Panel 的按钮,我可以关闭 Form2 但我无法隐藏 Panel1
You can subscribe to the Form.Closed
event on Form2.您可以订阅 Form2 上的Form.Closed
事件。 Here you can add code for hiding the panel.您可以在此处添加用于隐藏面板的代码。
Form2 f = new Form2();
f.TopLevel = false;
f.FormClosed += Form2_FormClosed; //Add this line
panel1.Controls.Add(f);
f.Show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.