vcl-cxgridcustomtableview-dot-tcxcustomgridtablecontroller-8835db01.md
Specifies the index of the focused record.
property FocusedRecordIndex: Integer read; write;
| Type | Description |
|---|---|
| Integer |
The focused record’s index.
|
You can use the FocusedRecordIndex property to focus a record.
When the View loads all records from a data source (the GridMode property is set to False ), FocusedRecordIndex specifies the record position relative to the top View record.
In grid mode, a data controller loads only a fixed number of records into a memory buffer. When you scroll the View contents and reach the end of the buffer, the data controller loads the next portion of records and focus is moved to a record within the new buffer.
Use the FocusedRecord property to access the record rather than its index. The Focused/Selected Records document provides more information related to focused records.
The following code example expands the focused group row:
var
AView: TcxCustomGridTableView;
//...
AView := TcxCustomGridTableView(Grid.FocusedView);
if AView.Controller.FocusedRecord is TcxGridGroupRow then
begin
AView.Controller.FocusedRecord.Expand(True);
AView.Controller.FocusedRecordIndex := AView.Controller.FocusedRecordIndex +
AView.GroupedItemCount - FocusedRecord.Level;
end;
TcxCustomGridTableView *AView =
dynamic_cast<TcxCustomGridTableView*>(Grid->FocusedView);
TcxCustomGridTableController *AController = AView->Controller;
if (dynamic_cast<TcxGridGroupRow*>(AController->FocusedRecord)) {
AController->FocusedRecord->Expand(true);
AController->FocusedRecordIndex = AController->FocusedRecordIndex +
AView->GroupedItemCount - AController->FocusedRecord->Level;
}
See Also
TcxCustomGridRecord.Focused Property
TcxCustomGridTableController.FocusedRecord Property
TcxCustomGridTableController.FocusNextRecord Procedure
TcxCustomGridTableController.FocusNextRecordWithSelection Procedure
TcxCustomGridTableController.FocusRecord Procedure
TcxCustomGridTableController Class