Iterate through all forms in a project...


Author
Message
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
I can't seem to find out how to iterate through all the forms in a VB project. Why does this seem so difficult to do? I'm aware of the OpenForms property but I cant really open ALL the forms in my project just to iterate through them.



I can even find out how to reference a form if i have the name:

dim frm as form = Forms("Form1")



Anybody got any advice?
Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I'm not sure why the OpenForms property doesn't work for you... the OpenForms collection only contains instances of the forms that are currently open within the application.  So, when you first start the app and you only have the one form up, then the OpenForms collection is only going to contain that one form.  If you have 2 of the same type of form open, then the collection will contain the object references to both of those forms.  You shouldn't have to "open" any of the forms in the OpenForms collection because they're already open.

However, if you want to iterate through all of the form types in your application, then you'll need to do like Greg said and do a Me.GetType().Assembly.GetTypes() and test each type for IsSubclassOf() to get all of the form types in your app.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search