RAD Studio |  |

Navigating Datasets
See Also
Collapse All

Each active dataset has a cursor, or pointer, to the current row in the dataset. The current row in a dataset is the one whose field values currently show in single-field, data-aware controls on a form, such as TDBEdit, TDBLabel, and TDBMemo. If the dataset supports editing, the current record contains the values that can be manipulated by edit, insert, and delete methods.

You can change the current row by moving the cursor to point at a different row. The following table lists methods you can use in application code to move to different records:

Navigational methods of datasets

Method | Moves the Cursor to
First | The first row in a dataset.
Last | The last row in a dataset. (not available for unidirectional datasets)
Next | The next row in a dataset.
Prior | The previous row in a dataset. (not available for unidirectional datasets)
MoveBy | A specified number of rows forward or back in a dataset.

The data-aware, visual component TDBNavigator encapsulates these methods as buttons that users can click to move among records at runtime. For information about the navigator component, see Navigating and manipulating records.

Whenever you change the current record using one of these methods (or by other methods that navigate based on a search criterion), the dataset receives two events: BeforeScroll (before leaving the current record) and AfterScroll (after arriving at the new record). You can use these events to update your user interface (for example, to update a status bar that indicates information about the current record).

TDataSet also defines two boolean properties that provide useful information when iterating through the records in a dataset.

Navigational properties of datasets

Property | Description
BOF (Beginning-of-file) | True: the cursor is at the first row in the dataset. False: the cursor is not known to be at the first row in the dataset
EOF (End-of-file) | True: the cursor is at the last row in the dataset. False: the cursor is not known to be at the first row in the dataset

The following topics discuss these properties and methods in more detail:

- Using the First and Last methods
- Using the Next and Prior methods
- Using the MoveBy method
- Using the Eof and Bof Properties
- Marking and Returning to Records

See Also

Modifying Data

Types of Datasets

Opening and Closing Datasets

Determining Dataset States

Searching Datasets

Displaying and Editing a Subset of Data Using Filters

Navigating Records in a Filtered Dataset

Calculating Fields

Using TDataSet Descendants

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