项目中所有表格的清单 [英] List of all Forms in Project

查看:85
本文介绍了项目中所有表格的清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行一个代码来扫描我的所有表单以检索一些关于我的控件的信息

。我现在可以在表单中运行它我现在想要

为我项目中的所有表单运行此代码所以我可以收集

我所有的信息形式。我的子开头是这样的:私人

Sub DoIt(ByVal frm as Form)


jean-luc
www.corobori.com

I need to run a code to scan all my forms to retrieve some information
about my controls. I can run it when I am in a form now I would like
to run this code for all my forms in my project so I can collection
that information for all my forms. My sub starts with this: Private
Sub DoIt(ByVal frm as Form)

jean-luc
www.corobori.com

推荐答案

* < a href =mailto:jl **** @ corobori.com> jl **** @ corobori.com (Corobori)scripsit:
* jl****@corobori.com (Corobori) scripsit:
我需要运行一个代码来扫描我的所有表单以检索有关我的控件的一些信息。我现在可以在表单中运行它,我希望
为我项目中的所有表单运行此代码,这样我就可以收集所有表单的信息。我的子开头是这样的:私有
Sub DoIt(ByVal frm as Form)
I need to run a code to scan all my forms to retrieve some information
about my controls. I can run it when I am in a form now I would like
to run this code for all my forms in my project so I can collection
that information for all my forms. My sub starts with this: Private
Sub DoIt(ByVal frm as Form)




您必须存储对所有表单的引用,例如,一个

''ArrayList''。然后你可以通过这个列表循环并在

所有表格上调用你的方法。


-

Herfried K. Wagner [MVP]

< http://dotnet.mvps.org/>



You will have to store references to all your forms, for example, in an
''ArrayList''. Then you can loop though this list and call your method on
all the forms.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>


然后你可以这样做......

Dim cFormType as System.Type

Dim cAssembly as System.Reflection.Assembly

Dim curType as Type

Dim curTypes()as Type


cAssembly = System.Reflection.Assembly.GetExecutingAssembly

cFormType = gettype(System.Windows.Forms.Form)

curTypes = cAssembly.GetTypes()

curTypes中每个curType的



如果typeof curType是cFormType那么

...在这里做你的东西

结束如果


next


这只是关闭我的头脑但应该工作......可能需要一点点

调整。


" Herfried K. Wagner [MVP] " <喜*************** @ gmx.at>在留言中写道

news:c1 ************* @ ID-208219.news.uni-berlin.de ...
And then you can do this...
Dim cFormType as System.Type
Dim cAssembly as System.Reflection.Assembly
Dim curType as Type
Dim curTypes() as Type

cAssembly = System.Reflection.Assembly.GetExecutingAssembly
cFormType = gettype(System.Windows.Forms.Form)
curTypes = cAssembly.GetTypes()

for each curType in curTypes

if typeof curType is cFormType then
... do your stuff here
end if

next

this is just off the top of my head but should work... may need a little
adjustment.


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c1*************@ID-208219.news.uni-berlin.de...
* jl****@corobori.com (Corobori)scripsit:
* jl****@corobori.com (Corobori) scripsit:
我需要运行一个代码扫描我的所有表单以检索有关我的控件的一些信息。我现在可以在表单中运行它,我希望
为我项目中的所有表单运行此代码,这样我就可以收集所有表单的信息。我的子开头是这样的:私人
Sub DoIt(ByVal frm as Form)
I need to run a code to scan all my forms to retrieve some information
about my controls. I can run it when I am in a form now I would like
to run this code for all my forms in my project so I can collection
that information for all my forms. My sub starts with this: Private
Sub DoIt(ByVal frm as Form)



你必须存储对所有表单的引用,例如,在
''ArrayList''。然后你可以通过这个列表循环并在
所有表格上调用你的方法。

-
Herfried K. Wagner [MVP]
< http:/ /dotnet.mvps.org/>



You will have to store references to all your forms, for example, in an
''ArrayList''. Then you can loop though this list and call your method on
all the forms.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>



*" CJ Taylor" <无**** @ blowgoats.com> scripsit:
* "CJ Taylor" <no****@blowgoats.com> scripsit:
然后你可以这样做...
And then you can do this...




....代码将循环通过程序集中定义的类型,而不是

表格实例。


-

Herfried K. Wagner [MVP]

< http://dotnet.mvps.org/>



.... the code will loop though the types defined in the assembly, not the
instances of forms.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>


这篇关于项目中所有表格的清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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