如何使用C#关闭.net中的多形式 [英] how to close mulitpule forms in .net with c#

查看:58
本文介绍了如何使用C#关闭.net中的多形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我不知道如何使用C#在.net中关闭多个表单

例如

1)第一页是登录页面

2)第二页是操作页

成功登录后,第一页应被隐藏,第二页将被打开,完成所有操作后,我必须关闭"X"按钮,两页应被关闭.

请为上述任何一个问题提供帮助.

谢谢您的进步..

Hi Friends,

I do not know how to close multiple form in .net with c#

For example

1) first page is login page

2) second page is operation page

after successful login first, first page should be hide, second page will open , after complete all the operation i have to close the "X" button, two page should be close .

Please help on any one above issue.

Thank you for advance..

推荐答案

您不应该保持登录页面打开.如果您的用户成功登录,则应打开主表单并关闭登录表单.这样的事情(如果用户成功登录,请在登录表单中放入此方法,然后调用它):-

You shouldn''t keep your login page open. If your user logs in successfully you should open your main form and close the login form. Something like this (put this method in you login form and call it if the user successfully logs in):-

void ShowMainWindow()
{
    form mainForm = new MainForm();
    mainForm.Show();
    //this.Dispose();
    this.Close();
}



如果需要处理登录表单中使用的任何资源,则应将要处理的调用放在登录表单中的Dispose方法中,并从上述方法中调用它.然后,当您的用户想要退出应用程序时,您可以仅关闭主窗体.

希望这会有所帮助.



If you need to dispose of any resources used in the login form you should put the calls to dispose in the login forms Dispose method and call this from the above method. Then you can just close the main form when your user wants to exit the application.

Hope this helps.


这篇关于如何使用C#关闭.net中的多形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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