c#
Winform关闭登陆窗口打开主窗口的方法
Program.cs中代码
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 form1 = new Form1();
if (form1.ShowDialog() == DialogResult.OK)
{
Application.Run(new Form2());
}
}
}
登录窗体(Form1)中代码
private void button1_Click(object sender, EventArgs e)
{
if (txtUserName.Text == "123" && txtUsePwd.Text == "123")
{
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("帐号或密码错误 ");
}
}