Windows form instance calculation
-
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.....
-
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.....
-
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.
can you plz explain it more.... plzzzz little e.g will be more helpful.... thanks a lot in advance.....
-
can you plz explain it more.... plzzzz little e.g will be more helpful.... thanks a lot in advance.....
-
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
thank u very much..... u r gr8... simple and perfert....... thank u.....
-
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.....
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; } }