Freigeben über


BindControls Property

Specifies when data binding occurs for data-bound controls.

Visual FoxPro usually binds the controls to the data source when the form loads. However, you can use BindControls to specify when data binding occurs for various reasons, such as to improve performance or to delay binding controls to the data source until the user performs an action, after the form loads, or until the data is needed.

Note   BindControls is intended for use when initially displaying a form and for binding controls after displaying the form. Although you can set BindControls to False (.F.) and back to True (.T.), BindControls is not intended for unbinding and rebinding controls at run time.

Form.BindControls [= lValue]

Property Values

Logical data type. The following table lists the values for lValue.

lValue Description
True (.T.) The Control.ControlSource or Grid.RecordSource binds to data when the form loads. (Default)

If Form.BindControls = .T. and Control.ControlSource or Grid.RecordSource is changed, the control is rebound. If Form.BindControls is changed from .T. to .F., current bindings are not changed.

False (.F.) The Control.ControlSource or Grid.RecordSource does not bind to data when the form loads.

If Form.BindControls = .F. and Control.ControlSource or Grid.RecordSource is changed, the control is not rebound, but the ControlSource property or Recordsource property is changed. If Form.BindControls is changed from .F. to .T., all controls in the form are rebound according to the current value of Control.ControlSource or Grid.RecordSource.

Example

Suppose a form needs to load a large number of tables or has a grid or other controls that bind to a cursor produced by a SQL statement that takes a long time to run. When the user launches the form, the form does not appear until it completely loads all the data.

By setting BindControls to False (.F.), the form appears immediately. You can then change BindControls to True (.T.) when the form is activated such as when the FormActivate event occurs and display a message such as "Please wait while loading data." The user then sees the form immediately along with a message that explains the delay in loading data instead of waiting for the form to appear.

See Also

Form Object Properties, Methods and Events

Applies To: Form Object