vcl-dxspreadsheetactions-60a4af28.md
An action object that implements the ChangeFillColor end-user command in Spreadsheet and Report Designer-based applications.
TdxSpreadSheetChangeFillColor = class(
TdxSpreadSheetValueAction,
IdxActionColorValue
)
This class does not introduce any new public members. The TdxSpreadSheetChangeFillColor action object is designed to be used in a Ribbon or Toolbar UI by the following item controls:
TcxColorComboBoxRepresents a color combo box control.TdxRibbonColorGalleryItemA bar item that provides advanced color selection capabilities.
A color picked by an end-user via a TcxBarEditItem UI element is automatically applied to all selected cells as their background color.
If you need to link a TdxSpreadSheetChangeFillColor action object to a custom client control, re-implement the action’s functionality in its OnExecute event handler. Otherwise, executing this action object via custom client controls has no effect.
In order to re-implement the functionality of a TdxSpreadSheetChangeFillColor action object for linking it to a custom client control, refer to the following code example:
procedure TSpreadSheetControlForm.dxSpreadSheetChangeFillColor1Execute(Sender: TObject);
var
ATableView: TdxSpreadSheetTableView;
ACell: TdxSpreadSheetCell;
I, J, K: Integer; // Counters
begin
ATableView := dxSpreadSheet1.ActiveSheetAsTable;
if(ATableView.Selection.Count > 0) then
begin
ATableView.BeginUpdate; // Stops worksheet repainting until the new background color is applied to all affected cells
for I := 0 to ATableView.Selection.Count - 1 do // Cycles through all selected cell ranges
for J := ATableView.Selection.Items[I].Left to ATableView.Selection.Items[I].Right do // Cycles through all columns within one selected cell area
for K := ATableView.Selection.Items[I].Top to ATableView.Selection.Items[I].Bottom do // Cycles through all rows within one selected cell area
begin
ACell := ATableView.CreateCell(K, J); // Obtains every cell object within one selected area
ACell.Style.Brush.BackgroundColor := clRed; // Here you can specify any color instead of red
end;
ATableView.EndUpdate; // Enables worksheet repainting to display the pending changes
end;
end;
void __fastcall TSpreadSheetControlForm::dxSpreadSheetChangeFillColor1Execute(TObject *Sender)
{
TdxSpreadSheetTableView *ATableView;
TdxSpreadSheetCell *ACell;
ATableView = dxSpreadSheet1->ActiveSheetAsTable;
if(ATableView->Selection->Count > 0)
{
ATableView->BeginUpdate(); // Stops worksheet repainting until the new background color is applied to all affected cells
for(int I = 0; I < ATableView->Selection->Count; I++) // Cycles through all selected cell ranges
for(int J = ATableView->Selection->Items[I]->Left; J <= ATableView->Selection->Items[I]->Right; J++) // Cycles through all columns within one selected cell area
for(int K = ATableView->Selection->Items[I]->Top; K <= ATableView->Selection->Items[I]->Bottom; K++) // Cycles through all rows within one selected cell area
{
ACell = ATableView->CreateCell(K, J); // Obtains every cell object within one selected area
ACell->Style->Brush->BackgroundColor = clRed; // Here you can specify any color instead of red
}
}
ATableView->EndUpdate(); // Enables worksheet repainting to display the pending changes
}
UI elements linked to a TdxSpreadSheetChangeFillColor action object are enabled only if the following conditions are met:
True).False).True).If no cells can be selected in the protected worksheet (i.e., its OptionsProtection.ActualAllowSelectUnlockedCells property returns False), executing the TdxSpreadSheetChangeFillColor action object has no effect.
Show 15 items
TObject TPersistent TComponent TBasicAction TContainedAction TCustomAction TAction TdxBasicAction TdxCustomAction TdxSpreadSheetAction TdxSpreadSheetCustomEditAction TdxSpreadSheetCustomEditCellsAction TdxSpreadSheetCustomFormatCellsAction TdxSpreadSheetValueAction TdxSpreadSheetChangeFillColor
See Also
TdxSpreadSheetChangeFontSize Class
TdxSpreadSheetChangeFontColor Class
TdxSpreadSheetChangeFontName Class