在Form2的页面加载期间关闭Form1 [英] Close Form1 during page load of Form2

查看:95
本文介绍了在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.


这篇关于在Form2的页面加载期间关闭Form1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆