List of all Forms in Project

  • Thread starter Thread starter Corobori
  • Start date Start date
C

Corobori

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
 
* (e-mail address removed) (Corobori) scripsit:
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)

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.
 
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.
 
* "CJ Taylor said:
And then you can do this...

.... the code will loop though the types defined in the assembly, not the
instances of forms.
 
I think there is confusion then... does he want to know all the active
forms? Or just forms contained in the project.
 
* "CJ Taylor said:
I think there is confusion then... does he want to know all the active
forms? Or just forms contained in the project.

Mhm... Who knows...
 
CJ Taylor said:
I think there is confusion then... does he want to know all the active
forms? Or just forms contained in the project.

I want to know all the forms contained in my project.
 
This one?


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

Since he isn't looking for instances, how does your statement hold water?
 
* "CJ Taylor said:
This one?


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

Since he isn't looking for instances, how does your statement hold water?

His statement IMO still isn't clear.
 
Back
Top