TcxCustomGridTableView.ConditionalFormatting Property
Provides access to the conditional formatting controller.
#Declaration
property ConditionalFormatting: TcxDataControllerConditionalFormatting read;
#Property Value
Type | Description |
---|---|
Tcx |
The grid View’s conditional formatting controller. |
#Remarks
Use the ConditionalFormatting
property to manage conditional formatting rules in the grid View.
You can call the ConditionalFormatting
.ShowRulesManagerDialog procedure to display the Conditional Formatting Rules Manager dialog or call the ConditionalFormatting
.Add procedure to apply a new conditional formatting rule to the grid View.
Refer to the TcxDataControllerConditionalFormatting class description for detailed information on all available options.
#Code Examples
#Create a Data Bar Rule
The following code example creates a data bar conditional formatting rule and applies it to a column in a TcxGrid control’s data-aware Table View:
var
ARule: TdxSpreadSheetConditionalFormattingRuleDataBar;
begin
cxGrid1DBTableView1.ConditionalFormatting.Add(cxGrid1DBTableView1Column1.Caption,
TdxSpreadSheetConditionalFormattingRuleDataBar, ARule);
ARule.BeginUpdate; // Initiates the following batch change
try
ARule.Style.NegativeBarColor := clRed;
ARule.Style.NegativeBarBorderColor := clRed;
ARule.Style.PositiveBarColor := clGreen;
ARule.Style.PositiveBarBorderColor := clGreen;
ARule.Style.FillMode := dbfmSolid;
finally
ARule.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
#Create an Icon Set Rule
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:
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;