Skip to main content

TdxSpreadSheetTableViewSelection.Items Property

Provides indexed access to selected cell ranges.

Declaration

property Items[Index: Integer]: TcxRect read; default;

Property Value

Type Description
TcxRect

Cell range boundaries, in row and column indexes.

Remarks

Use this property to access individual selected cells and cell ranges by their indexes. The indexes reflect the order of selection (areas with lower indexes were selected earlier).

The following code example uses the Items property to fill the background of all selected cells with the yellow color (clYellow):

var
  ATableView: TdxSpreadSheetTableView;
  ACell: TdxSpreadSheetCell;
  I, J, K: Integer;
begin
  ATableView := dxSpreadSheet1.ActiveSheetAsTable;
  ATableView.BeginUpdate; // Stops worksheet redraw operations
  for I := 0 to ATableView.Selection.Count - 1 do // Iterates through all selected cell ranges
  begin
    // Iterates through cell rows within the current cell range
    for J := ATableView.Selection.Items[I].Top to ATableView.Selection.Items[I].Bottom do
    begin
      // Iterates through cells within the current row
      for K := ATableView.Selection.Items[I].Left to ATableView.Selection.Items[I].Right do
      begin
        ACell := ATableView.CreateCell(J, K);
        ACell.Style.Brush.BackgroundColor := clYellow;
      end;
    end;
  end;
  ATableView.EndUpdate; // Resumes worksheet redraw operations and applies the visual changes
end;

Highlight Cell Selection Example

See Also