Windows窗体上的注销选项 [英] Log Out Option on Windows Form

查看:70
本文介绍了Windows窗体上的注销选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用VB.NET 2005开发了一个基于Windows的应用程序.它运行良好.现在,客户端要添加一个名为注销"的选项.选中此选项后,所有打开的窗口表单都应关闭,MDI表单需要打开,并且登录表单位于其顶部.

任何人都可以建议解决该问题的方法.

问候,Sachin

I have developed a windows based application using VB.NET 2005. It is working perfectly fine. Now the client wants to add an option called "Logout". When this is selected, all the open windows forms should get closed, the MDI form need to get opened with the login form on top of it.

Can anyone please suggest as to what can be done to sort out this matter.

Regards, Sachin

推荐答案

通过所有形式",我假设您是指MDI父级的任何子级.

如果是这样,这很容易.子窗口位于名为 MdiChildren [ ^ ] ,这只是Form的数组.只需遍历此数组即可调用每种表单的Close()方法.

您可能需要整理掉所有已挂起的资源,关闭后隐藏的MDI子项不会被丢弃.
By "all the forms" I assume you mean any child forms of the MDI parent.

If so this is easy. The child windows are available in a property called MdiChildren[^], this is just an array of Form. Just loop through this array calling each form''s Close() methods.

You may need to tidy up any resources you have hanging over, hidden MDI childen aren''t disposed when they are closed.


添加一个链接按钮,然后单击以添加此代码. br/>
Add one link button and on click add this code..

Protected void LinkLogOut_click(Object sender, EventArgs e)
{
    foreach(Form fm in Application.OpenForms)
    {
         if(fm.Name !="LoginForm")
         {
             fm.close();
         }
    }
}



希望这对您有帮助.



hope this helps..


很简单,您可以创建一种方法来关闭所有表单,最后只显示您的Login表单.例如:
It''s very simple you can make a method to close all the forms and at the end just show your Login form.Example :
Private Sub CloseAllForms()
   Form1.Close()
   Form2.Close()
   Form3.Close()
   'Write all the forms you used in your application no matter form is Open or Close 
   'If any form is open then this method will close that form
   'After closing all forms just show your Login Form
   FrmLogin.Show()
End Sub


在注销按钮上调用上述方法.

-MKB:)


Call above method on LogOut Button.

-MKB :)


这篇关于Windows窗体上的注销选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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