是否有任何属性可以知道哪个表单在后台运行 [英] is there any property for knowing which form is running in background

查看:53
本文介绍了是否有任何属性可以知道哪个表单在后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个窗口表单,我有1个窗体中的按钮和form2中的按钮,
如果单击form1按钮,则为
,然后它将form2显示为

form2 f2 = new form2();

f2.show();



并且form1仍然在后台并且可见,

并且当单击该按钮时,form2上还有一个按钮发生了同一事件,即form2在后台运行并且form3显示,

现在当form3显示我要隐藏form1

我该怎么做?

是否有任何属性可以帮助我知道后面运行的是哪种形式。

解决方案

最好的方法是在Form2处理Form2中创建一个事件。当Form2显示Form3时,它将事件发送到Form1,它隐藏了自己。



您还必须为Form1提供一个事件来重新显示自己,显然!

 Form1 f1 =(Form1)Application.OpenForms [Form1]; 
f1.Hide();


i have three windows forms, i have a button in the form 1 and a button in the form2,
if form1 button is clicked, then it shows the form2 as
form2 f2 = new form2();
f2.show();

and the form1 is still in the background and visible,
and there is one more button on the form2 when that button is clicked the same event happen that form2 is running in background and form3 shows up,
and now when the form3 is shown i want to hide the form1
how can i do that?
is there any property that can help me to know which form is running in behind.

解决方案

The best way is for you to create an event in Form2 which Form1 handles. When Form2 shows Form3, it signals the event to Form1 which hides itself.

You would also have to provide an event for Form1 to redisplay itself, clearly!


Form1 f1 = (Form1)Application.OpenForms["Form1"];
f1.Hide();


这篇关于是否有任何属性可以知道哪个表单在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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