473,322 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Use class instance over solution

Hi there..

I have a question about instance usage...
I created a VStudio 2003 solution within 3 projects as follow:

1) Proj One: Main form
2) Proj Two: User Control
3) Proj Three: Class

I need to instance the class in project three ad use the same instance in
the user
control. i.e. I need to set a property of class in project three and use it
in the
User Control

Any ideas??

I hope to be quite clear...
Thanks in advance
Nov 16 '05 #1
2 1380
Hi,

Use the Singleton design pattern for the class. In essence, you keep the
sole instance of the class in a private static variable of the class, you
make the class constructor private, and you have a public static property
called Instance returning the sole instance. The code of the Instance
property checks whether the instance has been created, and if not, creates
it and returns the reference to the instance to the caller.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"gaetanog" <ga******@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi there..

I have a question about instance usage...
I created a VStudio 2003 solution within 3 projects as follow:

1) Proj One: Main form
2) Proj Two: User Control
3) Proj Three: Class

I need to instance the class in project three ad use the same instance in
the user
control. i.e. I need to set a property of class in project three and use it in the
User Control

Any ideas??

I hope to be quite clear...
Thanks in advance


Nov 16 '05 #2
Hi,

Remember one thing, the projects are a logic split intended only to
facilitate the development , at runtime you only have one application no
matter how you divided it at development time.
That said, if you want to have one instance in the running application you
should use the Singleton pattern, or make the members static.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"gaetanog" <ga******@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi there..

I have a question about instance usage...
I created a VStudio 2003 solution within 3 projects as follow:

1) Proj One: Main form
2) Proj Two: User Control
3) Proj Three: Class

I need to instance the class in project three ad use the same instance in
the user
control. i.e. I need to set a property of class in project three and use it in the
User Control

Any ideas??

I hope to be quite clear...
Thanks in advance

Nov 16 '05 #3

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

Similar topics

6
by: Andre Meyer | last post by:
Hi all I have been searching everywhere for this, but have not found a solution, yet. What I need is to create an object that is an instance of a class (NOT a class instance!) of which I only...
50
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong...
1
by: Nobody You Know | last post by:
I need a member variable in class A known within an instance of class B, even though B does not instantiate A. My solution was to make the member variable private static, and create a public...
17
by: bengamin | last post by:
Hi, I have a C# class and two instance of the class; the class have some property. I want to compare the property value of the two instance How should i do? override == ? use delegate ?
23
by: patang | last post by:
When I create my own class, to use the functions of that class I have to create an object of that class and then I can access the functions of that class, for example: dim obj1 as myclass...
14
by: Dave Booker | last post by:
It looks like the language is trying to prevent me from doing this sort of thing. Nevertheless, the following compiles, and I'd like to know why it doesn't work the way it should: public class...
12
by: titan nyquist | last post by:
I have a class with data and methods that use it. Everything is contained perfectly THE PROBLEM: A separate thread has to call a method in the current instantiation of this class. There is...
6
by: Grok | last post by:
In writing a class library, one of the classes should only ever be instantiated once, and its object should be accessible to every other class in the library. How can I do that? To provide some...
36
by: Peter Olcott | last post by:
So far the only way that I found to do this was by making a single global instance of the container class and providing access to the contained class, through this single global instance. Are...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.