Enabled
This property determines whether a
control or form can get focus. It's Visual FoxPro's equivalent to
FoxPro 2.x's SHOW GET ENABLE | DISABLE.
Usage
|
oObject.Enabled = lValue
lValue = oObject.Enabled
|
When Enabled is .F., the object is dimmed. In addition,
you can't click on the object. Okay, you can click on it, but
nothing happens. You can't tab to it, either. Grids behave a
little differently than other controls in this regard. If you
disable the control in a column of a grid, then click on that
control, the grid cell itself receives "focus" of some sort. You
can't use the control, but the cell is highlighted. You still
can't tab into that control.Disable controls when they don't make
sense. By selectively enabling and disabling controls based on
the responses of the user, you can both encourage and shepherd
the users along the path of "normal" choices and prevent them
from choosing inappropriate or nonsensical choices.There's one
potential gotcha with Enabled. When you disable a container (like
a form), the objects in that container (like controls) are
inaccessible, but they don't get dimmed, so there's no visual cue
to the user. We like the fact that disabling the container keeps
users away from the contents—it would be a pain to have to cycle
through the contents and disable them individually. We just wish
there were an easy way to get a visual cue. Our best suggestion
is to create a custom method for the container, EnableIt, which
accepts .T. or .F., then issues SetAll(Enabled, <the passed
value>), followed by This.Enabled = <the passed value>.
Use the custom method instead of simply setting Enabled for the
container. Starting in VFP 6, you can use an Assign method of the
Enabled property of a container to do this.
Example
|
* You may want to enable the Save button of a dialog
* as soon as the user makes a change to a particular field.
* You could put something like this in the InteractiveChange
* method of that field:
ThisForm.btnSave.Enabled=.T.
|
Back to Table of Contents
Copyright © 2002-2018 by Tamar E. Granor,
Ted Roche, Doug Hennig, and Della Martin. Click for license
.