Solved

Access object from more than one form

Posted on 2011-03-23
1
292 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
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now