RAD Studio |  |

Using the First and Last Methods
See Also
Collapse All

The First method moves the cursor to the first row in a dataset and sets the BOF property to True. If the cursor is already at the first row in the dataset, First does nothing.

For example, the following code moves to the first record in CustTable:

Copy Code

    CustTable.First;

Copy Code

    CustTable->First();

The Last method moves the cursor to the last row in a dataset and sets the EOF property to True. If the cursor is already at the last row in the dataset, Last does nothing.

The following code moves to the last record in CustTable:

Copy Code

    CustTable.Last;

Copy Code

    CustTable->Last();

Note: The Last method raises an exception in unidirectional datasets.
Tip: While there may be programmatic reasons to move to the first or last rows in a dataset without user intervention, you can also enable your users to navigate from record to record using the TDBNavigator component. The navigator component contains buttons that, when active and visible, enable a user to move to the first and last rows of an active dataset. The OnClick events for these buttons call the First and Last methods of the dataset. For more information about making effective use of the navigator component, see Navigating and manipulating records.
See Also

Using the Next and Prior Methods

Using the MoveBy Method

Using the Eof and Bof Properties

Marking and Returning to Records

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