Re: Adding Property to Commandbutton
- From: tim_witort@xxxxxxxxxxx (Tim Witort)
- Date: Thu, 27 Jul 2006 16:36:18 +0000 (UTC)
wickedbusa seemed to utter in news:1153764864.875497.237500
@s13g2000cwa.googlegroups.com:
Hello eveyone. I need some help with a pretty simple task. I need to
add an additional property to a command button so that depending on the
user, the button is either enabled or disabled. I have a login screen
that checks a user's security level and depending on the number, I want
to be able to tell the command button that if the user's access level
is >= to that particular command button's property, then enable the
button. If not, then disable the button. Any sample code would be
appreciated.
Subclass the standard button class and add a property called
MinAccessLevel. Then modify the refresh method thusly:
This.Enabled = (goApp.UserAccessLevel >= This.MinAccessLevel)
RETURN DODEFAULT()
On your global application object (goApp), add the
UserAccessLevel property where you can store the access
level of the current user. This allows you to just drop
one of these "access-level-sensitive" buttons on a form
and set one property on the button (the minimum access
level that the user needs in order to use the button) and
it will work. You could also hide the button rather
than disabling it by changing the refresh code to:
This.Visible = (goApp.UserAccessLevel >= This.MinAccessLevel)
RETURN DODEFAULT()
Since these buttons will never be enabled while a
particular user is using the program, it is often better
to hide the button rather than show it always disabled.
-- TRW
_______________________________________
t i m
a t
w i t o r t d o t c o m
_______________________________________
.
- References:
- Adding Property to Commandbutton
- From: wickedbusa
- Adding Property to Commandbutton
- Prev by Date: Re: Compiled .exe file doesn't run
- Next by Date: Re: VFP 6: Printing to PDF
- Previous by thread: Re: Adding Property to Commandbutton
- Next by thread: RE: Email w/OLE Automation and Novell Groupwise
- Index(es):
Relevant Pages
|