Back to Devexpress

TcxCustomGridTableController.FocusedRecordIndex Property

vcl-cxgridcustomtableview-dot-tcxcustomgridtablecontroller-8835db01.md

latest3.3 KB
Original Source

TcxCustomGridTableController.FocusedRecordIndex Property

Specifies the index of the focused record.

Declaration

delphi
property FocusedRecordIndex: Integer read; write;

Property Value

TypeDescription
Integer

The focused record’s index.

|

Remarks

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.

Code Example: Expand the Focused Group Row

The following code example expands the focused group row:

delphi
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;
cpp
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

TcxCustomGridTableController Members

cxGridCustomTableView Unit