Back to Devexpress

TdxSpreadSheetConditionalFormattingRuleTopBottomValues.Direction Property

vcl-dxspreadsheetconditionalformattingrules-dot-tdxspreadsheetconditionalformattingruletopbottomvalues-a944c195.md

latest6.4 KB
Original Source

TdxSpreadSheetConditionalFormattingRuleTopBottomValues.Direction Property

Specifies if the rule applies custom formatting to top or bottom values in target cell ranges.

Declaration

delphi
property Direction: TdxSpreadSheetConditionalFormattingRuleTopBottomValuesDirection read; write; default tbvdTop;

Property Value

TypeDefaultDescription
TdxSpreadSheetConditionalFormattingRuleTopBottomValuesDirectiontbvdTop

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:

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 Direction property’s default value is tbvdTop.

See Also

TdxSpreadSheetConditionalFormattingRuleTopBottomValues.Value Property

TdxSpreadSheetConditionalFormattingRuleTopBottomValues.ValueType Property

TdxSpreadSheetConditionalFormattingRuleTopBottomValues Class

TdxSpreadSheetConditionalFormattingRuleTopBottomValues Members

dxSpreadSheetConditionalFormattingRules Unit