Back to Devexpress

TdxSpreadSheetConditionalFormattingRuleTopBottomValues.ValueType Property

vcl-dxspreadsheetconditionalformattingrules-dot-tdxspreadsheetconditionalformattingruletopbottomvalues.md

latest5.8 KB
Original Source

TdxSpreadSheetConditionalFormattingRuleTopBottomValues.ValueType Property

Specifies if the rule applies custom formatting to an absolute or relative number of cells.

Declaration

delphi
property ValueType: TdxSpreadSheetConditionalFormattingRuleTopBottomValuesValueType read; write; default tbvvtRank;

Property Value

TypeDefaultDescription
TdxSpreadSheetConditionalFormattingRuleTopBottomValuesValueTypetbvvtRank

The active target cell identification mode.

|

Remarks

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.

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:

delphi
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;
cpp
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
  }

Default Value

The ValueType property’s default value is tbvvtRank.

See Also

TdxSpreadSheetConditionalFormattingRuleTopBottomValues Class

TdxSpreadSheetConditionalFormattingRuleTopBottomValues Members

dxSpreadSheetConditionalFormattingRules Unit