none
WinFrom 切换用户 RRS feed

  • 问题

  • FrmLogin:登陆界面
    From1:主界面

    </cc><//cc>

    所遇问题:主界面里有一个切换用户菜单,点击跳转到登陆界面(FrmLogin);当用户输入正确用户名和密码时,就跳到主界面;就又可以切换用户了,等于跳进一个死循环里了。登陆几次就有几个主界面,又不能隐藏关闭...

    求解!!!

    </cc><//cc>
    2014年3月30日 14:17

答案

  • 楼主用this.Hidde()方法来隐藏掉上一个页面:

    FrmLogin

    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                if (this.textBox1.Text == "AAA" && this.textBox2.Text == "123456")
                {
                    Form2 f2 = new Form2();
    
                    f2.Show();
    
                    this.Hide();
                }
            }
        }

    From1

    public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Form1 f1 = new Form1();
    
                f1.Show();
    
                this.Hide();
            }
        }
    楼主可以试下


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年3月31日 5:45
    版主