Results 1 to 3 of 3

Thread: [RESOLVED] Looping all open forms

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Resolved [RESOLVED] Looping all open forms

    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...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Looping all open forms

    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.

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Looping all open forms

    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width