How to call a form and hide the previous one in C#?

Asked

Viewed 3,235 times

0

I’m in the middle of designing for college and I’m having a hard time.

The system has a Form main and when I call the second Form the main remains visible. How do I hide the form main while the second is open?

The code to call the second form and that:

F_CalcSimples F_CalcSimples = new F_CalcSimples();

F_CalcSimples.ShowDialog();

If anyone can help, thank you very much!

2 answers

4

Use the property Visible of your form which serves to return or define if an object is visible, see the example:

private void button1_Click(object sender, EventArgs e)
{
    this.Visible = false;

    Form2 meu_segundo_form = new Form2();
    meu_segundo_form.ShowDialog();

    this.Visible = true;
}

More information here.

More about the property Visible.

0

private void BtnLogin_Click(object sender, EventArgs e)
        {
                this.Hide();
                frmTelaPrincipal novo = new frmTelaPrincipal();
                novo.Show();
        }
  • novo.ShowDialog(); and in seguida this.Show();.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.