活动表格状态检查 [英] Active Form Status check

查看:81
本文介绍了活动表格状态检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Friends

如何检查一个应用程序中有多少表格处于活动状态?以及如果打开多个表单,如何关闭任何一个表单?请帮忙.

Hi Friends

How to check how many form is active in an application? and how to close any one form if multiple forms are open? please help.

推荐答案

嘿,有活动表格属性可以获取活动表格
喜欢
Hey there is Active form Property present to get active form
like
Form.ActiveForm



如果要关闭此表单,则只需调用它的close方法.



And if you want to close this form then just called close method of it.

Form.ActiveForm.close()



试试吧.



Try its.
its just suggestion!


如果这是标准的WinForms应用程序(与MDI应用程序相对),除非您打开了无模式的表单,否则只有一个活动表单,而该表单就是该表单你在看.

现在,如果您正在谈论当前*打开*多少个表格,那么您必须在每个表格打开时为其设置父属性,这意味着您必须将父表格传递给孩子(我是将在构造函数中执行此操作).完成此操作后,可以通过级联每个Parent属性,从当前表单向后遍历表单,直到读取未指定父级的属性.

想知道计数是没有意义的,但这就是我要怎么做.
If this is a standard WinForms app (as opposed to an MDI app), there is only one active form unless you have modeless forms open, and that form is the one you''re looking at.

Now, if you;''re talking about how many forms are currently *open*, then you have to set the parent property in each form as it is open, which means you have to pass the parent form to the child (I''d do that in the constructor). Once you''ve done that, you can travers the forms backwards from the current form by cascading each Parent property until you read one that doesn''t have a parent specified.

It''s kind pointless to want to know the count, but that''s how I''d do it.


尝试这个
Form.ActiveForm.ActiveMdiChild


就像桑托什所说的那样


and also as santosh said

Form.ActiveForm.ActiveMdiChild.Close();


希望我能帮忙
:-)


I hope I helped
:-)


这篇关于活动表格状态检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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