Skip to main content

TcxCustomGridTableController.FocusedRecordIndex Property

Returns the index of the focused record.

Declaration

property FocusedRecordIndex: Integer read; write;

Property Value

Type
Integer

Remarks

You can use the FocusedRecordIndex property to get/set the focused record within the current View. FocusedRecordIndex addresses the focused record by its visual position within the View.

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 example checks whether a group row is focused. If so, it is expanded and the first data row under the group row is focused.

var
  AView: TcxCustomGridTableView;
//...
  AView := TcxCustomGridTableView(Grid.FocusedView);
  with AView.Controller do
    if FocusedRecord is TcxGridGroupRow then
    begin
      FocusedRecord.Expand(True);
      FocusedRecordIndex := FocusedRecordIndex +
        AView.GroupedItemCount - FocusedRecord.Level;
    end;
See Also