In article <(E-Mail Removed)>,
(E-Mail Removed)
says...
> I'm trying to cache a user object and gain access to it from a mutlipe
> forms.
>
> I have created a base class that all forms will inherit from. In this base
> class, I have a propery to a User class which I want to cache and reuse on
> all other forms so that I don't need to retrieve the user data from every
> screen.
>
> For every form that is open, there is a OnLoad override in the base class
> that will call the getuser method in the user class and this will check to
> see if there's a cached object or not.
>
> Is this possible?
Create a static (Shared in VB.NET) reference to your user object on your
main form. Something like this (C#):
public class MainForm : Form
{
private static UserObject _currentUser;
public static UserObject CurrentUser
{
get { return _currentUser; }
}
}
Somewhere in "MainForm", the user object is initialized and loaded. Now
all other forms can access "MainForm.CurrentUser" to retrieve the one
user object.
--
Patrick Steele
http://weblogs.asp.net/psteele