raimicq
raimicq

Reputation: 3

C# question - make form visible

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

Answers (4)

Henk Holterman
Henk Holterman

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

thecoop
thecoop

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

Nestor
Nestor

Reputation: 13990

Use the property Visible of the class Form.

Upvotes: 0

CesarGon
CesarGon

Reputation: 15345

Use the Form.Visible property, or the Form.Show() method.

Upvotes: 3

Related Questions