Re: Adding Property to Commandbutton

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
_______________________________________
.



Relevant Pages

  • Re: Preventing an application from staying in memory if closed improperly
    ... It is possible for the user to hit the X during ... I think disabling the X might be a good option. ... one point though that I'd like to mention about the "disable the Command ... Button's Enabled property is set to True. ...
    (microsoft.public.vb.general.discussion)
  • Re: Upgrade to XP fails for windows 2000 sp4
    ... If it does work you will find that with the Event Log disabled it will take a bit of time for the logon window to appear, ... If it doesn't work you can enable the service again from the RC by issuing the Enable command: ... If disabling the event log fails to get you past the error you can slave the disk in another Windows 2000/XP machine and use regedt32 to remotely edit: ... The article is for NT3.x 4.0 but it also applies to Windows 2000 and I'm 99.9% sure that it also applies to XP. ...
    (microsoft.public.windowsxp.basics)
  • Re: Lag only when on-line
    ... consider disabling TeaTimer, ive found it to be an irritating cause of some ... Startup, Digital Line Detect ... Lists this as a microsoft system app, but i dont have it on my system ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: mute usb microphone with keyboard
    ... surround your device IDs with double quotes like so: ... Repeated the command and it said disabled but microphone still ... The microphone actually plugs into a USB pod which then plugs into the USB ... Jack and repeat all of the above disabling attempts to no avail. ...
    (microsoft.public.windowsxp.general)
  • Re: Preventing an application from staying in memory if closed improperly
    ... It is possible for the user to hit the X during ... I think disabling the X might be a good option. ... one point though that I'd like to mention about the "disable the Command ... Button's Enabled property is set to True. ...
    (microsoft.public.vb.general.discussion)