Hackers Guide to Visual FoxPro 7.0
InteractiveChange, ProgrammaticChange
InteractiveChange and ProgrammaticChange give us the kind of control we've always wanted over changes in a form. These two alone made the upgrade from FoxPro 2.x to VFP worthwhile. InteractiveChange fires when a control's Value changes due to a user action. ProgrammaticChange fires when the Value changes because of something in code.| Usage | PROCEDURE InteractiveChange | ProgrammaticChange [ LPARAMETERS nIndex ] |
| | For most controls, InteractiveChange doesn't fire when you re-choose the same item you just chose. For example, clicking the OptionButton that's already chosen in a group doesn't fire InteractiveChange for the OptionGroup. (Most of the time, this makes sense to us, since the Value of the control hasn't changed.) CommandGroups are the exception. Pressing a button in a CommandGroup always fires InteractiveChange for the group. |
The place where the lack of firing is most counter-intuitive is with multi-select list boxes. If you click an item to select it, then Ctrl+click it to deselect it, InteractiveChange fires only the first time. Again, it's because Value hasn't changed, but, with multi-select, somehow it seems as if something must have changed. If this doesn't fire InteractiveChange, how about giving us an event it does fire?
| | In VFP 5.0a and earlier, changes to a combo's or list's Selected property do not fire ProgrammaticChange, even if doing so changes the object's Value. This is a bug, plain and simple. Fortunately, it was fixed in VFP 6. |
| Example | PROCEDURE InteractiveChange * This might be the InteractiveChange procedure for a text box * that is the only required input in a dialog. * Once the user has entered a value, we enable the OK button. ThisForm.cmdOK.Enabled = .T. RETURN |
| See Also | Valid, Value |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории