winform中的登录表单 [英] login form in winform

查看:93
本文介绍了winform中的登录表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要在win form应用程序中实现登录表单。

我的方案是: - 登录表单应该打开第一 - >使用正确的用户名和密码,用户应该能够登录 - >那么另一个页面应该打开,登录页面应该关闭。



问题是: - 因为登录页面是第一页,需要输入 Main()函数如下。



 static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new login());
}





打开另一个表格后,formname.show()如果我从登录页面退出,整个申请将退出。



请问如何在没有申请退出和登录表单的情况下打开另一个表格作为我的第一个表格?

解决方案

最简单的方法是将登录表单作为第一个表单。

然后,当他们正确登录时,创建一个新的实例形式,并挂钩到FormClosed事件。

 frmMain fm = new FrmMain(); 
fm.FormClosed + = new FormClosedEventHandler(frmMain_FormClosed);



使用Form.Show()显示新表单并在登录表单上使用隐藏。 />
当FormClosed事件触发时,您的处理程序可以使用Show()重新显示登录表单或退出应用程序。



如果设置登录表单ShowInTaskbar为false然后也不会出现图标。



ShowInTaskbar属性中的弗洛伊德滑动... [/ edit]


试试这种方式:



C#应用程序中的多个后续主表单 [ ^ ]


谢谢John Simmons真的有用!!!! !!!!!!:)

Hi,

I need to implement a login form in win form application.
My scenario is :- Login form should open first--> with correct user name and password user should be able to login--> then another page should open and login page should get closed.

Problem is:- Since log in page is the first page and it need to get put in Main() function like below.

static void Main()
{
   Application.EnableVisualStyles();
   Application.SetCompatibleTextRenderingDefault(false);
   Application.Run(new login());
}



After opening another form by formname.show() If I get exit from loginpage whole application will get exit.

Please how I can open another form without application exit and login form as my first form ?

解决方案

The easiest way is to make the login form the first form.
Then, when they have correctly logged in, create an instance of your new form, and hook into the FormClosed event.

frmMain fm = new FrmMain();
fm.FormClosed += new FormClosedEventHandler(frmMain_FormClosed);


Show the new form with Form.Show() and use Hide on your login form.
When the FormClosed event fires, your handler can either re-display the login form with Show() or exit the application.

If you set the login form ShowInTaskbar to false then no icon will appear either.

[edit]Freudian slip in the ShowInTaskbar property...[/edit]


Try it this way:

Multiple Subsequent Main Forms in C# Apps[^]


Thank you John Simmons that really worked!!!!!!!!!!:)


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

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