2
Answers

Advanced forms collection

michael

michael

16y
2.3k
1
Hello

I am trying to create a windows project with an advanced form collection.

What i'm trying to achieve:

a class called "Interfaces" containing all the forms in my project
e.g.
[CODE]
public class Interfaces
{
  private static Interfaces uniqueInstance;
  private Form1 form1;
  private Form2 form2;

    public static Interfaces GetInstance()
    {
      if (uniqueInstance == null)
      {
        uniqueInstance = new Interfaces();
      }
      return uniqueInstance;
    }//GetInstance

  public Form1 Form1
  {
    get
    {
       if(form1 == null || form1.IsDisposed)
       {
          form1 = new Form1();
       }
       return form1;
    {
  }
  public Form2 Form2
  {
    get
    {
       if(form2 == null || form2.IsDisposed)
       {
          form2 = new Form2();
       }
       return form2;
    {
  }
}//class Interfaces
[/CODE]

and when i'd like to open a form, i would use the following code:

[CODE]
Interfaces.GetInstance().Form1.Show();
[/CODE]

This works fine, as long as the form i'm trying to open doesn't have any parameters, however, how can i use the same method for showing my forms when it DOES have parameters?
e.g.
Form1 form = new Form1("tekst",id);

Thanks in advance
Answers (2)