关闭加载页面并打开登录表单 [英] close loading page and open login form

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

问题描述

我的启动表单已加载。我需要关闭加载表单并打开登录表单。我使用代码

this.Dispose();

this.Close();

frmLogin objS = new frmLogin();

objS.ShowDialog();



当我使用此代码时,我的应用程序关闭加载并最终登录我的应用程序退出。我不知道如何在最后一个表格关闭时设置属性。



可以任意帮助。



(关闭加载和打开登录表单)

My startup form is loading. I need to close the loading form and open login form. I use the code
this.Dispose();
this.Close();
frmLogin objS = new frmLogin();
objS.ShowDialog();

When i use this code my application close the loading and also login finally my application exits. I dont know how to set property when last form closes.

Can any1 help in this.

( Close loading and Open login form )

推荐答案

在主窗体Load()事件中你必须调用登录表单并管理登录结果:让主表单显示与否(根据用户输入)。

这是一个例子:



In the main form Load() event you have to invoke the Login form and to manage the result of the login: to let the main form to show or not (based on the user input).
Here is an example:

private void FileManagerForm_Load(object sender, EventArgs e)
        {
            //
            // Login into the application
            //
            this.Hide(); //Hide the main form, so login form will be shown first!
            if (!DoLogin())
            {
                this.Close();
                return;
            }
//
// Show the main form!
//
this.Show();
//...
}

 private bool DoLogin()
        {
            Logout();
            //
            // Try to login
            //
            Des3 des3 = new Des3();
            LoginForm form = new LoginForm()
                                 {
                                     UserName = Settings.Default.UserName,
                                     Password = String.IsNullOrEmpty(Settings.Default.Password) ? string.Empty : des3.Decrypt(Settings.Default.Password),
                                     CheckCredentials = Settings.Default.RememberMe,
                                     LoginFormParent = this
                                 };
            //
            if (DialogResult.OK != form.ShowDialog() || this.SessionGuid == null)
                return false;
...
}


这篇关于关闭加载页面并打开登录表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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