关闭多个表格 [英] Close multiple forms

查看:108
本文介绍了关闭多个表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经在C#中创建了三种形式.当我打开第二个表格时,我需要关闭上一个表格.
这个怎么做?谁能帮我.

谢谢

Hi
I have created three forms in C#. when i open second form I need to close previous form.
How to do this? Can anyone help me please.

Thanks

推荐答案

在Form1代码中:
In the Form1 code:
Form2 f2 = new Form2();
f2.Show();
Close();


唯一的问题是,如果当前窗体是您的主窗体(在Program.cs的Main方法中打开的窗体),则它将关闭应用程序.在这种情况下,请使用隐藏"而不是关闭",或者先隐藏它,然后使用显示对话框"而不是显示"-试试看,您将明白我的意思!


The only problem with this is that if the current form is your main form (the one that opens in the Main method of Program.cs) that this will close the application. In that case, use Hide instead of Close, or Hide it first, then use ShowDialog instead of Show - try it and you will see what I mean!


这篇关于关闭多个表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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