在Form2的页面加载期间关闭Form1
问题描述:
如何在打开窗口Form2时关闭Form1?
How to close Form1 when Window Form2 will open?
答
如果正在从Form1中打开Form2,则关闭它可能不是一个好主意.
如果Form1是应用程序的主要表单,则关闭它将结束应用程序,同时也关闭Form2.
如果要执行的操作是从Form1中打开Form2,然后隐藏Form1:
If Form2 is being opened from Form1, then it is probably not a good idea to close it.
If Form1 is the main form for the application, then closing it will end the application, closing Form2 as well.
If what you want to do is open Form2 from Form1 and then hide Form1:
Form2 f2 = new Form2();
Hide();
f2.ShowDialog();
Show();
或
Form2 f2 = new Form2();
Hide();
f2.ShowDialog();
Close();
关闭Form2时将结束应用程序.
Which will end the app when Form2 is closed.