Form2 frm = new Form2();
frm.Show();
this.Hide();

解决方案 »

  1.   

    private void button1_Click(object sender, System.EventArgs e)
    {
    if(istrue(logname.Text,passwd.Text))
    {
    tt=true;
    this.Close();

    }
    else
    {
    this.Text="用户名或密码错误!";
    System.Diagnostics.EventLog.WriteEntry("personnel message",this.Text);
    }
    } public bool istrue(string s1,string s2)
    {
                db.OpenDB();
    string sql1="select * from log";
    db.OpenDBDataSet(sql1);
    DataSet ds1=db.GetDBDataSet();
    DataView dv=new DataView(ds1.Tables[0]);
    dv.Sort="logname";
    DataRowView[] drv=dv.FindRows(s1);
    if(drv.Length==1&&drv[0][1].ToString().Trim()==s2) return true;
    else return false;
    }
      

  2.   

    自我感觉下面的代码是最爽的,资源消耗最少的
                   [STAThread]
    static void Main() 
    {

    Form3 pswd = new Form3();//密码框
    pswd.ShowDialog();

    if(pswd.beright == true)
                    Application.Run(new Form1()); else
    Application.ExitThread();

    }
      

  3.   

    请问 HNU :
        你这个方法是不错。但是遇到了另外一个问题。
        登陆界面的用户名你怎么保存?
        也就是说,你怎么把已经在登陆界面中成功登陆的用户的ID(或者是信息)传递给主窗体呢?