vcl-cxgridcustomtableview-dot-tcxcustomgridtableview-5fc0a8a8.md
Provides access to the conditional formatting controller.
property ConditionalFormatting: TcxDataControllerConditionalFormatting read;
| Type | Description |
|---|---|
| TcxDataControllerConditionalFormatting |
The grid View’s conditional formatting controller.
|
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.
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;
TdxSpreadSheetConditionalFormattingRuleDataBar *ARule;
// ...
cxGrid1DBTableView1->ConditionalFormatting->Add(cxGrid1DBTableView1Column1->Caption,
__classid(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
}
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;
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
}
See Also
TcxCustomTreeList.ConditionalFormatting Property
TcxCustomVerticalGrid.ConditionalFormatting Property
TdxSpreadSheetTableView.ConditionalFormatting Property