1,运行代码:

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
           // Application.Run(new Form1());


            LoginForm lg = new LoginForm();
            if (lg.ShowDialog() == DialogResult.OK)
            {
                Application.Run(new Form1());// 打开你指定的窗口 
        } 

        }

2, 登录窗口(LoginForm)中 

在 你完成密码验证代码后加上
this.DialogResult=DialogResult.OK;

=====================================

建 议:

第一,最好把LoginForm窗口的FormBorderStyle属性改为:FixedDialog
这样,当 LoginForm窗口有关闭按钮时,只需要设置该按钮属性DialogResult为:Cancel
而不需要在关闭按钮事件里面写 上:this.close();

第二,设置LoginForm窗口的AcceptButton属性为登录按钮,CancelButton 为关闭按钮,
这样,就可以用回车直接登录和用Esc键直接关闭。

第三,设置LoginForm窗口的MaximizeBox属性 为:False
posted on 2010-02-05 15:32  superlee  阅读(986)  评论(1编辑  收藏  举报