vcl-dxspreadsheetconditionalformattingrules-dot-tdxspreadsheetconditionalformattingruletopbottomvalues.md
Specifies if the rule applies custom formatting to an absolute or relative number of cells.
property ValueType: TdxSpreadSheetConditionalFormattingRuleTopBottomValuesValueType read; write; default tbvvtRank;
| Type | Default | Description |
|---|---|---|
| TdxSpreadSheetConditionalFormattingRuleTopBottomValuesValueType | tbvvtRank |
The active target cell identification mode.
|
The Value property specifies the absolute or relative number of target cells. You can set the ValueType property to tbvvtPercent or tbvvtRank to switch between percentage and absolute cell count modes.
To switch between top and bottom cell value formatting modes, use the Direction property.
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;
TdxSpreadSheetTableView *ATableView;
TdxSpreadSheetConditionalFormattingRuleTopBottomValues *ATopBottomRule;
// ...
ATableView = dxSpreadSheet1->ActiveSheetAsTable;
if(ATableView->Selection->Count == 0) { return; }
ATableView->ConditionalFormatting->BeginUpdate(); // Initiates the following batch change
try
{
ATableView->ConditionalFormatting->Add(ATableView->Selection->Area,
__classid(TdxSpreadSheetConditionalFormattingRuleTopBottomValues), &ATopBottomRule);
ATopBottomRule->Style->Brush->BackgroundColor = clBlue;
ATopBottomRule->Style->Brush->ForegroundColor = clPurple;
ATopBottomRule->Style->Brush->Style = sscfsRevDiagonalStrip;
ATopBottomRule->Style->Font->Style = TFontStyles() << fsBold;
ATopBottomRule->Style->Font->Color = clWhite;
ATopBottomRule->Direction = tbvdTop;
ATopBottomRule->ValueType = tbvvtPercent;
ATableView->ConditionalFormatting->Add(ATableView->Selection->Area,
__classid(TdxSpreadSheetConditionalFormattingRuleTopBottomValues), &ATopBottomRule);
ATopBottomRule->Style->Brush->BackgroundColor = clGreen;
ATopBottomRule->Style->Brush->ForegroundColor = clLime;
ATopBottomRule->Style->Brush->Style = sscfsDiagonalStrip;
ATopBottomRule->Style->Font->Color = clWhite;
ATopBottomRule->Style->Font->Style = TFontStyles() << fsBold;
ATopBottomRule->Direction = tbvdTop;
ATopBottomRule->ValueType = tbvvtPercent;
}
__finally
{
ATableView->ConditionalFormatting->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
The ValueType property’s default value is tbvvtRank.
See Also
TdxSpreadSheetConditionalFormattingRuleTopBottomValues Class
TdxSpreadSheetConditionalFormattingRuleTopBottomValues Members