Skip to main content

TcxCustomGridTableController.FocusNextRecord(Integer,Boolean,Boolean,Boolean,Boolean) Method

Moves focus to the next or previous record while preserving the existing selection.

Declaration

function FocusNextRecord(AFocusedRecordIndex: Integer; AGoForward: Boolean; AGoOnCycle: Boolean; AGoIntoDetail: Boolean; AGoOutOfDetail: Boolean): Boolean;

Parameters

Name Type
AFocusedRecordIndex Integer
AGoForward Boolean
AGoOnCycle Boolean
AGoIntoDetail Boolean
AGoOutOfDetail Boolean

Returns

Type
Boolean

Remarks

You can use the FocusNextRecord method to navigate records within the current View. The FocusNextRecord method is called internally when a user navigates a View using the keyboard arrow keys. The method does not change the selection within the View.

FocusNextRecord moves focus relatively to the record identified by the AFocusedRecordIndex parameter. If AGoForward is True, FocusNextRecord focuses the next record. Otherwise, the previous record is focused. If a new record was focused successfully, FocusNextRecord returns True.

The method will cycle once it reaches the last item if the AGoOnCycle parameter is True. A forward search, will be continued from the first record when it reaches the last record. Similarly, when searching backward, the FocusNextRecord function returns the index of the last record if AFocusedRecordIndex addresses the first record.

To set focus to the first record, you can use the GoToFirst method. The FocusNextRecord(-1, True, False, AGoIntoDetail, AGoOutOfDetail) also focuses the first record. The FocusNextRecord(-1, False, True, AGoIntoDetail, AGoOutOfDetail) will set focus to the last record. Use also the GoToLast method for this purpose.

Set the AGoIntoDetail parameter to True to enable moving focus from a master View to a detail View (the detail View must be expanded). For instance, if the currently focused record is a master row, the following code focuses the first detail record.

var AGoOnCycle: Boolean;
//...
AGoOnCycle := ...;
with AView.Controller do
  FocusNextRecord(FocusedRecordIndex, True, AGoOnCycle, True, False);

Set the AGoOutOfDetail parameter to True to enable moving focus from the last record in a detail View to the master row which is next to the master row that corresponds to the detail View.

See Also