TdxSpreadSheetConditionalFormattingRuleStyleBased.Style Property
In This Article
Provides access to style settings applied to all cells that meet the rule’s formatting criteria.
#Declaration
Delphi
property Style: TdxSpreadSheetCellStyle read; write;
#Property Value
Type | Description |
---|---|
Tdx |
Stores spreadsheet cell style settings. |
#Remarks
Use Style
.Brush.Background, Style
.Brush.Style, and Style
.Brush.ForegroundColor properties to specify fill colors and a fill pattern for all affected cells within target cell ranges.
Refer to the TdxSpreadSheetCellStyle class description for detailed information on all available cell appearance customization options.
#Code Example: Create and Configure Two Conditional Formatting Rules
The following code example creates Duplicate and Unique value conditional formatting rules with different custom cell styles and applies these rules to the last selected cell range in the active worksheet in a TdxSpreadSheet control:
var
ATableView: TdxSpreadSheetTableView;
ADuplicateValuesRule: TdxSpreadSheetConditionalFormattingRuleDuplicateValues;
AUniqueValuesRule: TdxSpreadSheetConditionalFormattingRuleUniqueValues;
begin
ATableView := dxSpreadSheet1.ActiveSheetAsTable;
if ATableView.Selection.Count = 0 then Exit;
ATableView.ConditionalFormatting.BeginUpdate; // Initiates the following batch change
try
ATableView.ConditionalFormatting.Add(ATableView.Selection.Area,
TdxSpreadSheetConditionalFormattingRuleDuplicateValues, ADuplicateValuesRule);
ADuplicateValuesRule.Style.Brush.BackgroundColor := clBlue;
ADuplicateValuesRule.Style.Brush.ForegroundColor := clNavy;
ADuplicateValuesRule.Style.Brush.Style := sscfsRevDiagonalStrip;
ADuplicateValuesRule.Style.Font.Color := clWhite;
ADuplicateValuesRule.Style.Font.Style := [fsBold, fsItalic];
ATableView.ConditionalFormatting.Add(ATableView.Selection.Area,
TdxSpreadSheetConditionalFormattingRuleUniqueValues, AUniqueValuesRule);
AUniqueValuesRule.Style.Brush.BackgroundColor := clLime;
AUniqueValuesRule.Style.Brush.ForegroundColor := clGreen;
AUniqueValuesRule.Style.Brush.Style := sscfsDiagonalStrip;
AUniqueValuesRule.Style.Font.Color := clWhite;
AUniqueValuesRule.Style.Font.Style := [fsBold];
finally
ATableView.ConditionalFormatting.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
See Also