Database Programming Techniques > Changing the Current Record Position > Using the navigation methods |
When the grid is bound to a Data control, you can manipulate the underlying Recordset using Data control properties and methods such as EOF, MoveFirst, and MoveNext. However, if you decide later on to switch to an unbound data source, these properties and methods will be unavailable.
True DBGrid solves this problem by providing properties and methods that mimic those supported by Recordset objects. These properties and methods work the same for all DataMode settings, thus eliminating the need to write separate implementations for bound and unbound modes.
Moves the current record to the first record available. |
|
Moves the current record to the last record available. |
|
Moves the current record to the next record available. |
|
Moves the current record to the previous record available. |
|
Moves the current record according to a specified offset and optional bookmark. |
Only the MoveRelative method accepts arguments (a long integer offset and an optional variant bookmark). A positive offset indicates forward movement; a negative offset indicates backward movement. If the bookmark argument is omitted, the current row's bookmark is used. Thus, the following statements are all equivalent:
Example Title |
Copy Code
|
---|---|
TDBGrid1.MoveRelative -1, TDBGrid1.Bookmark TDBGrid1.MoveRelative -1 TDBGrid1.MovePrevious |