Reputation: 3
I made 2 forms in C# visual studio. How can I make one form invisible and another visible (Have done this in visual basic only before)
I guess Syntax should be similar.
Upvotes: 0
Views: 7187
Reputation: 273691
If I remember correctly, VB.NET will pre-create the forms for you, and you only have to call Show(). In C#, you will have to create all but the MainForm.
// in a buttonClick on Form1
Form2 f2 = new Form2();
f2.Show();
This will create a new instance each time you click the button.
Upvotes: 1
Reputation: 46148
To hide and show a form, use the Form.Visible property:
Form.Visible = true;
Form.Visible = false;
There's also methods that do the same thing (these are designed to be used with the MethodInvoker delegate):
Form.Show();
Form.Hide();
Upvotes: 3