T
Troy Bull
Greetings
I am trying to use a singleton to hold a group of forms. I have a
MDIMaster form. I have a class called Forms; Forms is a singleton. I
want to do something like the following.
In MDIMaster (and other forms), I want to get an instance of Forms (the
only instance). Inside Forms then there are public variables for each
of the possible forms, if a "form" has never been accessed the Forms
factory creates a new instance of the particular form and returns that
instance of it.
Basically I want a container that will keep track of all the currently
open forms, and make sure that no particular form is ever opened 2
times. This also effectively "registers" forms with the singleton so I
can send messages between different forms.
For my first example I tried adding an about box. In MDI Master under
the menu item help / about, I have the following code:
private void aToolStripMenuItem_Click(object sender, EventArgs e)
{
Forms.Instance.aboutBox.Show();
}
Inside my Forms class I have the following:
public AboutBox aboutBox
{
get
{
if (aboutBox == null)
{
aboutBox = new AboutBox();
}
return aboutBox;
}
}
I am getting an error :
Error 1 Inconsistent accessibility: property type 'AcroDesktop.AboutBox'
is less accessible than property 'AcroDesktop.Forms.aboutBox'
C:\Users\bull\Desktop\Acro\trunk\AcroDesktop\AcroDesktop\Forms.cs 14 25
AcroDesktop
I looked at the definition of AcroDesktop.AboutBox and it appears to be
public..
If anyone could give me any pointers I would really appreciate it, I
thought I had came up with a great idea here, until i tried to compile it
Is there some other way to do this? The main thing I want to get is the
registration part so that my forms can invoke one another, or send
messages to each other..
Troy
I am trying to use a singleton to hold a group of forms. I have a
MDIMaster form. I have a class called Forms; Forms is a singleton. I
want to do something like the following.
In MDIMaster (and other forms), I want to get an instance of Forms (the
only instance). Inside Forms then there are public variables for each
of the possible forms, if a "form" has never been accessed the Forms
factory creates a new instance of the particular form and returns that
instance of it.
Basically I want a container that will keep track of all the currently
open forms, and make sure that no particular form is ever opened 2
times. This also effectively "registers" forms with the singleton so I
can send messages between different forms.
For my first example I tried adding an about box. In MDI Master under
the menu item help / about, I have the following code:
private void aToolStripMenuItem_Click(object sender, EventArgs e)
{
Forms.Instance.aboutBox.Show();
}
Inside my Forms class I have the following:
public AboutBox aboutBox
{
get
{
if (aboutBox == null)
{
aboutBox = new AboutBox();
}
return aboutBox;
}
}
I am getting an error :
Error 1 Inconsistent accessibility: property type 'AcroDesktop.AboutBox'
is less accessible than property 'AcroDesktop.Forms.aboutBox'
C:\Users\bull\Desktop\Acro\trunk\AcroDesktop\AcroDesktop\Forms.cs 14 25
AcroDesktop
I looked at the definition of AcroDesktop.AboutBox and it appears to be
public..
If anyone could give me any pointers I would really appreciate it, I
thought I had came up with a great idea here, until i tried to compile it

Is there some other way to do this? The main thing I want to get is the
registration part so that my forms can invoke one another, or send
messages to each other..
Troy