在C#中隐藏和显示表单 [英] Hide and Show of Form in C#

查看:102
本文介绍了在C#中隐藏和显示表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:

如果我有两张表格。 Form1有一个计时器,可以增加计数器并显示在文本框中。如果我按下一个按钮,Form1将被隐藏但仍在后台处理,并将显示Form2。然后如果我按下Form2中的一个按钮,表格2将被隐藏,而Form1将再次显示(具有最新的计数器值)。


我该怎么办?


谢谢

解决方案

打开Form类的文档并浏览其中的所有方法。你想要的那个应该很容易被发现。


PS如果你没有文件或智能感知,拒绝写任何代码。


< blockquote>我在Form2中尝试创建一个新实例。


像这样:Form1 newForm = new Form1();

newForm.show();



但它是新实例,而不是在背景上运行的实例..



我在Form2中尝试创建一个新实例。


像这样:Form1 newForm = new Form1();

newForm.show() ;


但它是新实例,而不是在后台运行的实例..



使用您拥有的那些相同表单上的隐藏和显示方法。使用new关键字将创建一个新的(不同的)表单。


Hi:
If I have 2 forms. Form1 have a timer that increase a counter and display in a textbox. If I press a button Form1 will be hide but still in process in the background, and Form2 will be displayed. Then If I press a button in Form2, Form 2 will be hide while Form1 will be display again ( with the latest counter value).

How can i do it?

Thanks

解决方案

Open the docs for the Form class and browse through all the methods in it. The one you want should be easy to spot.

P.S Refuse to write any code if you don''t have either the docs or intellisense.


I tried in Form2 by creating a new instance.

Like this: Form1 newForm= new Form1();
newForm.show();


But that it the new instance, not the one that run on background..


I tried in Form2 by creating a new instance.

Like this: Form1 newForm= new Form1();
newForm.show();


But that it the new instance, not the one that run on background..

Use the Hide and Show methods on those same Forms that you have. Using the new keyword will create a, well, new (different) form.


这篇关于在C#中隐藏和显示表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆