Skip to main content

TdxServerModeDataController.LocateByKey(Variant) Method

Finds and focuses the record containing the specified key field values.

function LocateByKey(const AKeyFieldValues: Variant): Boolean;

Declaration

function LocateByKey(const AKeyFieldValues: Variant): Boolean;

Parameters

Name Type
AKeyFieldValues Variant

Returns

Type
Boolean

Remarks

This function locates the record with the specified key field value(s). The AKeyFieldValues parameter should specify a variant or an array of variant values corresponding to the key field(s) set via the KeyFieldNames property.

The function returns True when the appropriate record is found and focused (in ExpressQuantumGrid, the view’s OnFocusedRecordChanged event is fired when changing the focused record). If the record doesn’t exist or no key field names are assigned, LocateByKey returns False.

The LocateByKey method does not force the reloading of dataset data, since it searches its internal buffer.

The dataset’s Locate method also allows you to locate records with specific criteria. However, each call of Locate forces the data controller to reload data from the dataset, thus slowing down performance, especially for large datasets. To prevent data reloading when moving the cursor within the dataset, you can enclose call(s) to Locate within the BeginLocate and EndLocate methods.

See Also