Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. iterate over all the forms in a project

iterate over all the forms in a project

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrcooll
    wrote on last edited by
    #1

    hii 4 all How can i iterate over all the forms in my project? it is not mdi application i have tried application.openforms its not working!

    L 1 Reply Last reply
    0
    • M mrcooll

      hii 4 all How can i iterate over all the forms in my project? it is not mdi application i have tried application.openforms its not working!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If you create a new form, put it in a collection. For example : List

      forms = new List(); Form form1 = new Form(); forms.Add(form1); You can iterate it in this collection.

      M 1 Reply Last reply
      0
      • L Lost User

        If you create a new form, put it in a collection. For example : List

        forms = new List(); Form form1 = new Form(); forms.Add(form1); You can iterate it in this collection.

        M Offline
        M Offline
        mrcooll
        wrote on last edited by
        #3

        but , i want to get all of the forms in the project without creating object first, i tried foreach (Form frm in Application.OpenForms) but it just returns the opend forms only! :confused:

        N 1 Reply Last reply
        0
        • M mrcooll

          but , i want to get all of the forms in the project without creating object first, i tried foreach (Form frm in Application.OpenForms) but it just returns the opend forms only! :confused:

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          When you say "get all of the forms in the project" do you mean all the forms in a Visual Studio project, or all of the forms in a running application? The latter will require using reflection.


          only two letters away from being an asset

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups