winform 的一种登录方法。

program.cs    

    static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            login lf = new login();
            lf.ShowDialog();
            if (lf.DialogResult == DialogResult.Yes)
            {
                Application.Run(new main());
            }
        }

login.cs

    if (xxx)
            {
                MessageBox.Show("用户名和密码不正确");
            }
            else
            {

                this.DialogResult = DialogResult.Yes;
            }

原文地址:https://www.cnblogs.com/lsfv/p/3109977.html