Back to Devexpress

TdxSpreadSheetConditionalFormattingRuleIconSet Class

vcl-dxspreadsheetconditionalformattingrules-e0181242.md

latest10.3 KB
Original Source

TdxSpreadSheetConditionalFormattingRuleIconSet Class

An Icon Set conditional formatting rule.

Declaration

delphi
TdxSpreadSheetConditionalFormattingRuleIconSet = class(
    TdxSpreadSheetConditionalFormattingRuleCustomScale
)

Remarks

An Icon Set rule allows you to mark cell values with icons according to threshold values associated with the icons.

Main API Members

The list below outlines key members of the TdxSpreadSheetConditionalFormattingRuleDataBar class. These members allow you to configure Data Bar rule settings.

Common Rule API Members

AreasAllows you to manage the conditional formatting rule’s target areas.CloneCopies the rule between different sets of target areas.Index | StopIfTrueSpecify how the rule interacts with other conditional formatting rules applied to the same cells.

Rule-Specific API Members

OrderAllows you to change icon order in the current icon preset.PresetNameAllows you to switch between available icon presets.StopCountSpecifies the number of threshold values.StopsProvides indexed access to individual threshold values and related settings.ShowValueSpecifies if cell values are visible.

General-Purpose API Members

AssignCopies compatible settings between conditional formatting rules.BeginUpdate | EndUpdateAllow you to avoid excessive redraw operations during batch rule setting changes.GetDetailsReturns the conditional formatting rule’s name displayed in the Conditional Formatting Rules Manager dialog.LoadFromStream | SaveToStreamAllow you to store conditional formatting rule settings in a stream.OwnerProvides access to the parent conditional formatting controller.

Create an Icon Set Rule

To create an Icon Set conditional formatting rule, you can call one of the overloaded Add procedures of the corresponding conditional formatting controller and pass a reference to the TdxSpreadSheetConditionalFormattingRuleIconSet class as the ARuleClass parameter:

TcxDataControllerConditionalFormatting.AddCreates a new conditional formatting rule for a Data Grid, Tree List, or Vertical Grid control.TdxSpreadSheetConditionalFormatting.AddCreates a new conditional formatting rule in a spreadsheet document.

Alternatively, you can call the constructor of the TdxSpreadSheetConditionalFormattingRuleIconSet class and pass the target conditional formatting controller as the AOwner parameter.

Code Example: Apply an Icon Set Conditional Formatting Rule to a Data Grid Column

The following code example creates an Icon Set conditional formatting rule with three threshold values and applies the rule to the first column in a TcxGrid control’s data-aware Table View:

delphi
var
  ARule: TdxSpreadSheetConditionalFormattingRuleIconSet;
begin
  cxGrid1DBTableView1.ConditionalFormatting.Add(0, TdxSpreadSheetConditionalFormattingRuleIconSet, ARule);
  ARule.BeginUpdate; // Initiates the following batch change
  try
    ARule.PresetName := ConditionalFormattingIconSet.Presets.Items[1].Name;
    ARule.Stops[0].ValueType := cssvtValue;
    ARule.Stops[0].Value := 0;
    ARule.Stops[1].ValueType := cssvtValue;
    ARule.Stops[1].Value := 25;
    ARule.Stops[2].ValueType := cssvtValue;
    ARule.Stops[2].Value := 50;
  finally  
    ARule.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
  end;
end;
cpp
TdxSpreadSheetConditionalFormattingRuleIconSet *ARule;
// ...
  cxGrid1DBTableView1->ConditionalFormatting->Add(0, 
           __classid(TdxSpreadSheetConditionalFormattingRuleIconSet), &ARule);
  ARule->BeginUpdate(); // Initiates the following batch change
  try
  {
    ARule->PresetName = ConditionalFormattingIconSet()->Presets->Items[1]->Name;
    ARule->Stops[0]->ValueType = cssvtValue;
    ARule->Stops[0]->Value = 0;
    ARule->Stops[1]->ValueType = cssvtValue;
    ARule->Stops[1]->Value = 25;
    ARule->Stops[2]->ValueType = cssvtValue;
    ARule->Stops[2]->Value = 50;
  }
  __finally
  {
    ARule->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
  }

Delete a Conditional Formatting Rule

To delete an individual Icon Set conditional formatting rule, do one of the following:

Alternatively, you can call the TdxSpreadSheetCustomConditionalFormatting.Clear procedure to delete all rules in a conditional formatting controller.

Other Threshold-Based Conditional Formatting Rule Classes

You can also use the following threshold-based rules:

TdxSpreadSheetConditionalFormattingRuleDataBarA Data Bar conditional formatting rule.TdxSpreadSheetConditionalFormattingRuleThreeColorScaleA Three Color Scale conditional formatting rule.TdxSpreadSheetConditionalFormattingRuleTwoColorScaleA Two Color Scale conditional formatting rule.

Indirect TdxSpreadSheetConditionalFormattingRuleIconSet Class References

The TdxSpreadSheetCustomConditionalFormatting.Rules property references the TdxSpreadSheetConditionalFormattingRuleIconSet class as a TdxSpreadSheetCustomConditionalFormattingRule object.

To access all public API members, you need to cast the returned object to the TdxSpreadSheetConditionalFormattingRuleIconSet class. You can call the rule’s ClassType function to identify the actual rule type.

Inheritance

TObject TPersistent TInterfacedPersistent TcxInterfacedPersistent TdxSpreadSheetCustomConditionalFormattingRule TdxSpreadSheetConditionalFormattingCustomRule TdxSpreadSheetConditionalFormattingRuleCustomScale TdxSpreadSheetConditionalFormattingRuleIconSet

See Also

TdxSpreadSheetConditionalFormattingRuleCustomScale Class

TdxSpreadSheetConditionalFormattingRuleIconSet Members

dxSpreadSheetConditionalFormattingRules Unit