TdxSpreadSheetTableView.Selection Property
Provides access to the collection of selected cell ranges and objects in the worksheet.
Declaration
property Selection: TdxSpreadSheetTableViewSelection read;
Property Value
Type | Description |
---|---|
TdxSpreadSheetTableViewSelection | The collection of selected cell ranges and objects. |
Remarks
Use the Selection
property to access and manage selections in the worksheet.
Available Options
You can use the Selection
.Items property to access all individual selected cell ranges by their indexes. Selection
.Add, Selection
.Clear, Selection
.SelectAll, Selection
.SelectCell, Selection
.SelectColumns, and Selection
.SelectRows methods allow you to select or deselect cell ranges and individual cells.
Refer to the TdxSpreadSheetTableViewSelection class description for detailed information on all available options.
Code Example: Apply Custom Formatting to All Selected Cells
The following code example fills the background of all selected cells with yellow (the clYellow
color value):
var
ATableView: TdxSpreadSheetTableView;
ACell: TdxSpreadSheetCell;
I, J, K: Integer;
begin
ATableView := dxSpreadSheet1.ActiveSheetAsTable;
ATableView.BeginUpdate; // Starts the following batch change at the worksheet level
try
for I := 0 to ATableView.Selection.Count - 1 do // Iterates through all selected cell ranges
begin
// Iterates through all cell rows within the current cell range
for J := ATableView.Selection.Items[I].Top to ATableView.Selection.Items[I].Bottom do
begin
// Iterates through all 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;
finally
ATableView.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
See Also