PDA

View Full Version : c# advanced form collection



mpd
04-18-2008, 02:26 PM
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.


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


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



Interfaces.GetInstance().Form1.Show();


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?

Thanks in advance

mpd
04-18-2008, 05:00 PM
if anyone wondered what the solution is:



public Form1 Form1
{
get
{
if(form1 == null || form1.IsDisposed)
{
form1 = new Form1();
}
return form1;
{
set
{
form1 = value;
}
}

vikrant60
05-06-2008, 09:45 PM
Thanks