TdxSpreadSheetConditionalFormattingRuleTopBottomValues.Direction Property
Specifies if the rule applies custom formatting to top or bottom values in target cell ranges.
Declaration
property Direction: TdxSpreadSheetConditionalFormattingRuleTopBottomValuesDirection read; write; default tbvdTop;
Property Value
Type | Default | Description |
---|---|---|
TdxSpreadSheetConditionalFormattingRuleTopBottomValuesDirection | tbvdTop | The active Top/Bottom rule mode. |
Remarks
Set the Direction
property to tbvdBottom or tbvdTop to switch the Top/Bottom Values conditional formatting rule between Top and Bottom modes. To specify the number of affected cells in target cell ranges, use Value and ValueType properties.
Tip
To mark both top and bottom values in target cell ranges, you need to create two Top/Bottom Values rules with different Direction
property values and the same target cell ranges as demonstrated in the code example below.
Code Example: Apply Custom Formatting to Top and Bottom Values
The following code example creates two Top/Bottom Values conditional formatting rules and applies them to the top and bottom 10%
of values in the selected cell range in the currently visible worksheet in a TdxSpreadSheet control:
var
ATableView: TdxSpreadSheetTableView;
ATopBottomRule: TdxSpreadSheetConditionalFormattingRuleTopBottomValues;
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,
TdxSpreadSheetConditionalFormattingRuleTopBottomValues, ATopBottomRule);
ATopBottomRule.Style.Brush.BackgroundColor := clBlue;
ATopBottomRule.Style.Brush.ForegroundColor := clPurple;
ATopBottomRule.Style.Brush.Style := sscfsDiagonalStrip;
ATopBottomRule.Style.Font.Style := [fsBold];
ATopBottomRule.Style.Font.Color := clWhite;
ATopBottomRule.Direction := tbvdTop;
ATopBottomRule.ValueType := tbvvtPercent;
ATableView.ConditionalFormatting.Add(ATableView.Selection.Area,
TdxSpreadSheetConditionalFormattingRuleTopBottomValues, ATopBottomRule);
ATopBottomRule.Style.Brush.BackgroundColor := clGreen;
ATopBottomRule.Style.Brush.ForegroundColor := clLime;
ATopBottomRule.Style.Brush.Style := sscfsRevDiagonalStrip;
ATopBottomRule.Style.Font.Color := clWhite;
ATopBottomRule.Style.Font.Style := [fsBold];
ATopBottomRule.Direction := tbvdBottom;
ATopBottomRule.ValueType := tbvvtPercent;
finally
ATableView.ConditionalFormatting.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
Default Value
The Direction
property’s default value is tbvdTop.