473,397 Members | 1,949 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,397 software developers and data experts.

class user across multiple forms

If in form1 I use
User user = new User(); as a reference to my user object. When I go to
form2 how do I reference the same user?

Thanks
Mike
Nov 22 '05 #1
5 1010
If it is a global access to that instance you can consider to have a
"static class" style that will hold the reference of that instance or
you may store it in the appdomain storage
System.AppDomain.Current.SetData("key", user); and retrieve it from
anywhere of your application by calling
System.AppDomain.Current.GetData("key");

HTH
Erick Sgarbi
www.blog.csharpbox.com

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com:
If in form1 I use
User user = new User(); as a reference to my user object. When I go to
form2 how do I reference the same user?

Thanks
Mike


Nov 22 '05 #2
Thanks for the reply. I am a newbie to this so could you provide some sample
code or point me to a reference?

Thanks
Mike
"Erick Sgarbi" wrote:
If it is a global access to that instance you can consider to have a
"static class" style that will hold the reference of that instance or
you may store it in the appdomain storage
System.AppDomain.Current.SetData("key", user); and retrieve it from
anywhere of your application by calling
System.AppDomain.Current.GetData("key");

HTH
Erick Sgarbi
www.blog.csharpbox.com

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com:
If in form1 I use
User user = new User(); as a reference to my user object. When I go to
form2 how do I reference the same user?

Thanks
Mike


Nov 22 '05 #3
Thanks for the reply. I am a newbie to this so could you provide some sample
code or point me to a reference?

Thanks
Mike
"Erick Sgarbi" wrote:
If it is a global access to that instance you can consider to have a
"static class" style that will hold the reference of that instance or
you may store it in the appdomain storage
System.AppDomain.Current.SetData("key", user); and retrieve it from
anywhere of your application by calling
System.AppDomain.Current.GetData("key");

HTH
Erick Sgarbi
www.blog.csharpbox.com

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com:
If in form1 I use
User user = new User(); as a reference to my user object. When I go to
form2 how do I reference the same user?

Thanks
Mike


Nov 22 '05 #4
Can you provide a sample code? I am a newbie and this is greek to me.

Thanks
Mike

"Erick Sgarbi" wrote:
If it is a global access to that instance you can consider to have a
"static class" style that will hold the reference of that instance or
you may store it in the appdomain storage
System.AppDomain.Current.SetData("key", user); and retrieve it from
anywhere of your application by calling
System.AppDomain.Current.GetData("key");

HTH
Erick Sgarbi
www.blog.csharpbox.com

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com:
If in form1 I use
User user = new User(); as a reference to my user object. When I go to
form2 how do I reference the same user?

Thanks
Mike


Nov 22 '05 #5
Can you provide a sample code? I am a newbie and this is greek to me.

Thanks
Mike

"Erick Sgarbi" wrote:
If it is a global access to that instance you can consider to have a
"static class" style that will hold the reference of that instance or
you may store it in the appdomain storage
System.AppDomain.Current.SetData("key", user); and retrieve it from
anywhere of your application by calling
System.AppDomain.Current.GetData("key");

HTH
Erick Sgarbi
www.blog.csharpbox.com

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com:
If in form1 I use
User user = new User(); as a reference to my user object. When I go to
form2 how do I reference the same user?

Thanks
Mike


Nov 22 '05 #6

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

Similar topics

3
by: Mike | last post by:
If in form1 I use User user = new User(); as a reference to my user object. When I go to form2 how do I reference the same user? Thanks Mike
42
by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
15
by: Deano | last post by:
I've posted about this subject before but haven't really got anywhere yet. I have now come up with a plan of action that takes into account my strong desire to implement save/discard functionality...
4
by: Jay | last post by:
Is it possible to split a class up in multiple files? if so how?
7
by: erin.sebastian | last post by:
Hello Everyone, This is my first attempt at coding using an abstract class and i am getting an error i can't figure out. Here is the back ground. I have a project that contains an abstract...
2
by: Stephen Bartholomew | last post by:
Hi All, Firstly, apologies to anyone that notices the cross-post: i also posted this in microsoft.public.dotnet.general earlier this week. I have an ecommerce site that resides mainly on an...
2
by: Mervin Williams | last post by:
I am using Infragistics UltraWebTab (a tab folder control for ASP.NET). My tab folder control will include five tab pages with a separate web form on each, and these web forms will share data. ...
16
by: pawel.pabich | last post by:
Hajo, I would like to have 2 my own partial classes. For example: Default.aspx.cs Default2.aspx.cs and they both will relate to Default.aspx page.
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
4
by: =?Utf-8?B?RmFyaWJh?= | last post by:
It know that we can use the following method http://msdn2.microsoft.com/en-us/library/eb0zx8fc.aspx to form authenticate across multiple applications. I have created an asp.net application...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...
0
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,...

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.