delphi

Cxdbpivotgrid record number


How do I know the record number in a component cxdbpivotgrid in Delphi?

I try any time I asked chatGPT No result


Solution

  • The TcxDBPivotGrid component does not have a RecordNumber property, but we can get RecordIndex for a cell on which we are focused. Here is an example of how to work with RecordIndex. We will assume that your instance of TcxDBPivotGrid has a name cxDBPivotGrid1.

    var
      RecordIndex: Integer;
    begin
      RecordIndex := cxDBPivotGrid1.ViewData.Cells[cxDBPivotGrid1.ViewData.FocusedCell.Y,
        cxDBPivotGrid1.ViewData.FocusedCell.X].Owner.Row.RecordIndex;
      ShowMessage('Focused Record Index: ' + RecordIndex.ToString);
    end;
    

    BTW, data contained in TcxDBPivotGrid can have a source (e.g., Table, Query). A source can contain a property like RecordNumber.