static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); frmLogin frm = new frmLogin(); using (frm) { if (frm.ShowDialog() == DialogResult.OK)//内容验证密码通过this.DialogResult=DialogResult.OK; this.close(); { Application.Run(new frmMain(frm.userid, frm.power)); frm.Dispose(); } }
} } 我一般是这样的
一般我的做法。。 FormMian代码(主窗体)using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;namespace System { public partial class FormMain : Form { public FormMain() { InitializeComponent(); } private void FormMain_Load(object sender, EventArgs e) { FormLogin fl = new FormLogin(); bool Logined=false; do { if (fl.ShowDialog(this) == DialogResult.OK) { string u = "u"; string p = "p"; if (fl.UserID == u && fl.UserPwd == p) { Logined = true; fl.Close(); } else { MessageBox.Show("非法登陆", "管理员登陆", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { this.Close(); } } while(!Logined&&(fl.DialogResult==DialogResult.OK)); } } }二:FormLogin代码(验证窗体) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;namespace System { public partial class FormLogin : Form { public FormLogin() { InitializeComponent(); } private void btnExit_Click(object sender, EventArgs e) { Application.Exit();//exit } public String UserID { get { return tbUserID.Text; } } public String UserPwd { get { return tbUserPwd.Text; } } } }在这个窗体中要注意的是设置登陆按钮btnLogin的DialogResult属性为OK 你那个DLL的没做过~
frmMain frmMain = new frmMain();
DialogResult dt =frm.ShowDialog();
if(dt == DialogResult.OK)
{
Application.Run(frmMain);
}
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmLogin frm = new frmLogin();
using (frm)
{
if (frm.ShowDialog() == DialogResult.OK)//内容验证密码通过this.DialogResult=DialogResult.OK; this.close();
{
Application.Run(new frmMain(frm.userid, frm.power));
frm.Dispose();
}
}
}
}
我一般是这样的
FormMian代码(主窗体)using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace System
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
} private void FormMain_Load(object sender, EventArgs e)
{
FormLogin fl = new FormLogin();
bool Logined=false;
do
{
if (fl.ShowDialog(this) == DialogResult.OK)
{
string u = "u";
string p = "p";
if (fl.UserID == u && fl.UserPwd == p)
{
Logined = true;
fl.Close();
}
else
{
MessageBox.Show("非法登陆", "管理员登陆", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
} }
else
{
this.Close();
}
}
while(!Logined&&(fl.DialogResult==DialogResult.OK));
}
}
}二:FormLogin代码(验证窗体)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace System
{
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
} private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();//exit
}
public String UserID
{
get { return tbUserID.Text; }
}
public String UserPwd
{
get { return tbUserPwd.Text; }
}
}
}在这个窗体中要注意的是设置登陆按钮btnLogin的DialogResult属性为OK
你那个DLL的没做过~