473,770 Members | 6,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with "forms" container

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 aToolStripMenuI tem_Click(objec t 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.Ab outBox'
is less accessible than property 'AcroDesktop.Fo rms.aboutBox'
C:\Users\bull\D esktop\Acro\tru nk\AcroDesktop\ AcroDesktop\For ms.cs 14 25
AcroDesktop

I looked at the definition of AcroDesktop.Abo utBox 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
Jul 3 '07 #1
1 1823
On Tue, 03 Jul 2007 16:35:58 -0700, Troy Bull <tr*******@gmai l.comwrote:
Greetings
Hi.
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.
Question 1: let's clear up some terminology. What do you mean by "public
variables"? A class can have fields and properties. Do you mean "public
fields"? Or "public properties"?

Question 2: why do you want a singleton? So far, I haven't seen anything
that would suggest you need even a single instance of your Forms class.
Can't it just be a static class with a bunch of static fields and
properties? Or is it derived from some other class that's not a static
class, preventing you from making it static? Or does the class need to be
referenced at some point by some other class as an instance (like, putting
into a collection, or exposing some interface, or something like that)?
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.
Seems fine to me. But unless there's something else you need from this
class as well, I'm still not clear on the need to make it an instanced
class at all.
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 aToolStripMenuI tem_Click(objec t 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.Ab outBox'
is less accessible than property 'AcroDesktop.Fo rms.aboutBox'
C:\Users\bull\D esktop\Acro\tru nk\AcroDesktop\ AcroDesktop\For ms.cs 14 25
AcroDesktop

I looked at the definition of AcroDesktop.Abo utBox and it appears to be
public..
Well, apparently it's not. You haven't posted the relevant code. That
is, the code where the type is actually declared. But clearly, the type
"AcroDesktop.Ab outBox" is _not_ public. That's what the compiler is
telling you.

There may be some less-than-intuitive reason for this, but I don't think
the compiler would just yank your chain for the fun of it. If it says the
type's not public, then I'm sure it's not.
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..
The main thing I would change is not bother with making the Forms class a
singleton, unless you have some other need to refer to the class as an
actual instance. You haven't mentioned such a need so far, and the
functionality you're describing here can be done with a static class.

Pete
Jul 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1411
by: Simon Verona | last post by:
I know this is a little of topic, for which I apologise, but I think it's pertinent to .Net development so I hope it's ok to ask this question here! I'm looking to created filled in "forms" from my application eg Sales Orders, Quotations etc which have data filled in from my application. I want my users to be able to design their own form templates (eg to include their company logos, terms and conditions etc). The standard .Net...
5
5276
by: Harry | last post by:
Hi All, Can anyone clever out there tell me why the below script does not work! - I have a page with two radio boxes with values of "agree" and "not_agree". - The form is set to GET which goes to the below script for processing. - No matter which of the two radio boxes are selected, it always goes to the page "/broadband/order.asp".
0
1638
by: Woody Lemcke | last post by:
Hello all, Would you gurus please share your wisdom on any DB2 equivalents to the Informix "Forms" input form utility and "Ace" report generating utility? The input form will probably be accessed by telneting from a Linux shell or Windows command prompt and used for updating a lab database. Thanks and regards, Woody Lemcke
0
1219
by: gmarquez | last post by:
Hello, I am using "FORMS" authentication, without SSL the behavior is normal, everythings working very well. When in IIS I cheking "Require SSL" (in Secure Communications property), I can't to do login, after introducing the credentials, I am redirected to login's page again, If I take the SSL's Check off in the ISS property, everythings will work very well again. NOTE: I have a valid certificate well installed. What is happening?,...
0
5614
by: Angel | last post by:
Hi I have a problem with my web applications. I believe the problem is somehow connected to HttpSession. I use form authentication in my project. Once I authenticate the user and redirect to default page I create an User object and assign this object to session. Then in other forms I access this object and use it to load data from database. Some times I keep data in the object as a property of object. For example let say my object is...
6
1529
by: Alan Silver | last post by:
Hello, I have a page that displays a data list with info from a database. The grid has the usual stuff, edit, update, delete etc. Below this I have a section where they can add a new entry to the list. This has some text boxes for the data, and a button to click when they are ready to submit. To the user, this looks like two separate forms, one containing a grid of existing data and one where they add new data.
4
9917
by: Scott Johnson | last post by:
Hi! Is there a way to "preload" a form using a thread or something else so that my user doesn't have to wait 5 seconds (initializing time) between forms? Some of these forms have tab strips with lots of controls and database queries on them and I would like to try to have some(all) of the preloading of the next form and controls done in the background while a user is still entering data. (For example, my user visits screen A then B then...
1
1429
by: Dib | last post by:
Hi, how do I call a form to open from another form. example I have a frmLogIn and an frmError The frmError have a ListBox. If the frmLogin generated an error I want the error to show in the ListBox on frmError.
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.