TcxPivotGridViewDataSelection.Regions Property
Provides indexed access to cell regions making up the current selection.
Declaration
property Regions[AIndex: Integer]: TRect read; default;
Property Value
Type |
---|
TRect |
Remarks
To manage regions within the Regions collection, call the Add, MakeNew, Delete, and Clear methods. The Count property returns the number of items within this collection. Changes to this collection fire the pivot grid’s OnSelectionChanged event.
The following code example shows how to iterate through the Regions collection to calculate the sum of selected data cell values excluding subtotal and grand total values.
procedure <Form>.Button1Click(Sender: TObject);
var
I,X,Y,RightX,BottomY: Integer;
ASelection: TRect;
ACellSummary: Variant;
begin
ACellSummary := 0;
with PivotGrid.ViewData do
begin
for I := 0 to Selection.Count - 1 do
begin
ASelection := Selection.Regions[I];
RightX := Min(ASelection.Right, ColumnCount - 1);
BottomY := Min(ASelection.Bottom, RowCount - 1);
for X := ASelection.Left to RightX do
begin
for Y := ASelection.Top to BottomY do
if not (Rows[Y].IsTotalItem or Columns[X].IsTotalItem) then
ACellSummary := ACellSummary + Cells[Y,X].Sum;
end;
end;
end;
ShowMessage(VarToStr(ACellSummary));
end;
See Also
TcxPivotGridViewDataSelection.Regions