Hackers Guide to Visual FoxPro 7.0
ControlSource
This property lets you link (bind) a variable, field, or another property to a control's Value.| Usage | oObject.ControlSource = cSource cSource = oObject.ControlSource |
| | For lists and combos, ControlSource can be either character or numeric. When the ControlSource is numeric, its interpretation is determined by the control's BoundTo property. With the default .F. for BoundTo, Value (and the ControlSource) contains the position (or ListIndex) of the chosen item. To have a numeric value from the list's data stored in Value and the ControlSource, you have to set BoundTo to .T. |
Although the ControlSource is bound to the control's Value, the item named in ControlSource doesn't get updated until after the control's InteractiveChange is finished. Don't test the value of a ControlSource until you reach the Valid event—if you need to test sooner, test the control's Value. In fact, it's better OOP to refer only to the control's Value in its methods and not mention the ControlSource by name. If you reference the actual object named in ControlSource, the code is no longer well encapsulated and the control is no longer as easily reusable.
| Example | This.ControlSource = "Employee.Last_Name" |
| See Also | BoundTo, InteractiveChange, ListIndex, Valid, Value |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории