"Merlin" <iM*****@hotmail.com> wrote in message news:<c1**********@hercules.btinternet.com>...
Hi,
This is want I want to do, but not sure how to do it:-
I want to create a class that has events, for example a Class called
"Security" that has an event called "Security Changed", I then want to
attach this in some way to some forms and controls and then have the event
"Security Changed" visible in these. Then whenever I fire the event
"Security Changed" from anywhere all open forms/controls with the same event
attached also fire.
I'm after this functionality so that I can setup a password scheme, so that
a user by default has Read Only access to all program forms, but if they
then enter a password all open forms change to Full Access. There are many
ways to accomplish this but the way described above would be much more
manageable.
Is this possible?
Thanks.
Merlin
I possible way to do this is as follows:
In your User Object (the current user with security permissions)
create a property SecurityLevel or something similar
Also create an Event SecurityChanged, fire the event when
SecurityLevel changes
Create an Interface ILockable
Public Interface ILockable
Property Locked() As Boolean
End Interface
have each Form/UserControl implement ILockable
Public Overridable Property Locked() As Boolean Implements
ILockable.Locked
Get
Return m_Locked
End Get
Set(ByVal Value As Boolean)
m_Locked = Value
setLockedState(Value)
End Set
End Property
in each Form/UserControl create a Sub setLockedState(Value) that sets
the state of the controls on the form
In your main form add and handler for the User_SecurityChanged event,
loop though all open forms testing if they implement ILockable. If
they do, set the locked state.
Alternately, have each form listen for the User_SecurityChanged event
and Lock accordingly
k.