简体   繁体   English

切换为在Windows窗体之间隐藏和显示?

[英]Switching to hide and show between Windows Forms?

I have 2 forms Form1 and form2.First time Form2 is being load by below code and this is my sign in page.. 我有2个表单Form1和Form2。第一次通过下面的代码加载Form2,这是我的登录页面。

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. 但是登录后我想加载另一个Form1表单。我将如何加载它。如果我创建新的From2()这将使新表单没有在那里显示受人尊敬的控件。

How about this? 这个怎么样?

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

尝试以下...

Form2.Show();

I'd do something like this inside Form2 (or wherever you check the login data) 我会在Form2中(或无论您在何处检查登录数据)执行类似的操作

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!");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM