RAD Studio
ContentsIndex
PreviousUpNext
Using the First and Last Methods

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:

CustTable.First;

 

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:

CustTable.Last;

 

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.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!