Reputation:
How can i hide Form1 while Form2 is displayed?. I have tried this but it does not Hide Form1 when clicking the Button
private void button3_Click(object sender, EventArgs e)
{
Form2 scriptHub = new Form2();
scriptHub.Show();
Form1 mainScreen = new Form1();
mainScreen.Hide();
}
Upvotes: 0
Views: 43
Reputation: 483
You are creating a new Forms and hidding it quick after... You have to acces your current form. Use the Keyword "this":
this.Hide();
Your code should look like this:
private void button3_Click(object sender, EventArgs e)
{
Form2 scriptHub = new Form2();
scriptHub.Show();
this.Hide(); //Hide your mainscreen
}
Dont forget that you are hidding the forms and not closing it that means that your CPU will be more busy than if you colse it. Hope it helps
Upvotes: 1