How can I loop all open forms in a C# application?
Say I instantiate various new forms, how can I loop all these forms to look at their caption/text?
I feel like I'm explaining this horribly, but if anyone can help...
Printable View
How can I loop all open forms in a C# application?
Say I instantiate various new forms, how can I loop all these forms to look at their caption/text?
I feel like I'm explaining this horribly, but if anyone can help...
I think VB provides a forms collection for the benefit of classic VB programmers, but I don't believe C# does that.
As far as I know, you would have to have some sort of a collection (e.g. List<Form>) and add forms to it as you instantiate them, then loop through that.
Alternatively, you could make a "CountedForm" class or something that inherits from Form and manages the collection for you; and make your form classes inherit from that instead, so that you don't have to write management code as you instantiate them.
Alright. I was hoping there was something similiar to VB6.
No problem doing it myself, I was just looking for an easy button.
Thanks for your help.