Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxSpreadSheetConditionalFormattingRuleStyleBased.Style Property

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
TdxSpreadSheetCellStyle

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.

VCL Spreadsheet: Custom Fill Settings Applied to Affected Cells

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;

VCL Spreadsheet Controls: Unique and Duplicate Value Conditional Formatting Rules

See Also