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;
}