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. Windows form instance calculation

Windows form instance calculation

Scheduled Pinned Locked Moved C#
6 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.
  • C Offline
    C Offline
    chandler83
    wrote on last edited by
    #1

    hi all, in my application when i double click a list view it opens a new form... if i double click it again it again opens a new form again .... is thr any method to find out how many forms are opened already before opening a new dialog... thanks a million in advance.....

    L S 2 Replies Last reply
    0
    • C chandler83

      hi all, in my application when i double click a list view it opens a new form... if i double click it again it again opens a new form again .... is thr any method to find out how many forms are opened already before opening a new dialog... thanks a million in advance.....

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

      If you open a new form, you must put it in a collection. Then you can read the "Count" from collection to know how many forms are opened.

      C 1 Reply Last reply
      0
      • L Lost User

        If you open a new form, you must put it in a collection. Then you can read the "Count" from collection to know how many forms are opened.

        C Offline
        C Offline
        chandler83
        wrote on last edited by
        #3

        can you plz explain it more.... plzzzz little e.g will be more helpful.... thanks a lot in advance.....

        L 1 Reply Last reply
        0
        • C chandler83

          can you plz explain it more.... plzzzz little e.g will be more helpful.... thanks a lot in advance.....

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

          For example : Just create an ArrayList. ArrayList a = new ArrayList(); If you create a new form, for example: Form form = new Form(); a.Add(form); form.Show(); If you want to know the amount, then get the a.Count

          C 1 Reply Last reply
          0
          • L Lost User

            For example : Just create an ArrayList. ArrayList a = new ArrayList(); If you create a new form, for example: Form form = new Form(); a.Add(form); form.Show(); If you want to know the amount, then get the a.Count

            C Offline
            C Offline
            chandler83
            wrote on last edited by
            #5

            thank u very much..... u r gr8... simple and perfert....... thank u.....

            1 Reply Last reply
            0
            • C chandler83

              hi all, in my application when i double click a list view it opens a new form... if i double click it again it again opens a new form again .... is thr any method to find out how many forms are opened already before opening a new dialog... thanks a million in advance.....

              S Offline
              S Offline
              Shy Agam
              wrote on last edited by
              #6

              I would say that the prefered OOP style way is to use a Singleton object. A Singleton object is an object with no visible constructors. You declare every constructor as private, thus hiding them all. In order to get your single instance of the class, you create a static function which checks if an instance was already created. If it was, you return that existing instance. If not, you create a new one and return it. Example:

              public class SingletonClass
              {
                  SingletonClass instance;
              
                  private SingletonClass()
                  {
                      // Initialization code
                  }
              
                  public static SingletonClass GetInstance()
                  {
                      if (instance = null)
                          instance = new SingletonClass();
                      
                      return instance;
                  }
              }
              
              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