TdxSpreadSheetChangeFillColor Class
An action object that implements the ChangeFillColor end-user command in Spreadsheet and Report Designer-based applications.
Declaration
TdxSpreadSheetChangeFillColor = class(
TdxSpreadSheetValueAction,
IdxActionColorValue
)
Remarks
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:
- TcxColorComboBox
- Represents a color combo box control.
- TdxRibbonColorGalleryItem
- A 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;
UI elements linked to a TdxSpreadSheetChangeFillColor
action object are enabled only if the following conditions are met:
- Spreadsheet document editing is allowed (i.e., the control’s OptionsBehavior.Editing property is set to
True
). - An in-place cell editor is inactive (the active worksheet‘s IsEditing property returns
False
). - Cell formatting is allowed in the active worksheet (i.e., its OptionsProtection.ActualAllowFormatCells property returns
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.