Solved

Access object from more than one form

Posted on 2011-03-23
1
303 Views
Last Modified: 2012-06-21
I have an object that I need to access from two forms.

frmLogin
frmMain

On frmLogin I need to open the connection and validate the user.
On frmmain i will need to work with the methods and events of CmiServer


//frmLogin
frmMain.CmiServer.OpenConnection()


//frmMain
        public static CmiServer CmiServer
        {
            get
            {
                if (_cmiServer == null)
                {
                    _cmiServer = new CmiServer();
                }

                return _cmiServer;
            }
        }


Are there other/better ways to do this?
0
Comment
Question by:JRockFL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35202221
You really only have two options:
(1) Static members.
(2) Instantiate the class in the first class and then pass a reference to it into the second class.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question