开发者

C# question - make form visible

I made 2 forms in开发者_如何学Python 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.


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


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();


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.


Use the property Visible of the class Form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜