开发者

Switching to hide and show between Windows Forms?

I have 2 forms Form1 and form2.First time Form2 is being load by 开发者_如何学JAVA below code and this is my sign in page..

application.run(new form2())

But after sign in i want to load another form Form1.How will i load it.If i am creating new From2() this is making new form not showing respected controls there.


I'd do something like this inside Form2 (or wherever you check the login data)

private void btnLogIn_OnClick(...)
{
    if(/* perform credential test here */)
    {
        (new Form1()).Show(); // create and show the other form
        this.Close(); // close this form
    }
    else
        MessageBox.Show("Login invalid!");
}


How about this?

Form2 form = new Form2();
form.Show();


Try the following...

Form2.Show();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜