RAD Studio |  |

Navigating Records in a Filtered Dataset
See Also
Collapse All

There are four dataset methods that navigate among records in a filtered dataset. The following table lists these methods and describes what they do:

Filtered dataset navigational methods

Method | Purpose
FindFirst | Move to the first record that matches the current filter criteria. The search for the first matching record always begins at the first record in the unfiltered dataset.
FindLast | Move to the last record that matches the current filter criteria.
FindNext | Moves from the current record in the filtered dataset to the next one.
FindPrior | Move from the current record in the filtered dataset to the previous one.

For example, the following statement finds the first filtered record in a dataset:

Copy Code

    DataSet1.FindFirst;

Copy Code

    DataSet1->FindFirst();

Provided that you set the Filter property or create an OnFilterRecord event handler for your application, these methods position the cursor on the specified record regardless of whether filtering is currently enabled. If you call these methods when filtering is not enabled, then they

- Temporarily enable filtering.
- Position the cursor on a matching record if one is found.
- Disable filtering.

Note: If filtering is disabled and you do not set the Filter property or create an OnFilterRecord event handler, these methods do the same thing as First, Last, Next, and Prior.
All navigational filter methods position the cursor on a matching record (if one is found), make that record the current one, and return True. If a matching record is not found, the cursor position is unchanged, and these methods return False. You can check the status of the Found property to wrap these calls, and only take action when Found is True. For example, if the cursor is already on the last matching record in the dataset and you call FindNext, the method returns False, and the current record is unchanged.
See Also

Enabling and Disabling Filtering

Navigating Datasets

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!