Back to Devexpress

TcxCustomGridTableView.ConditionalFormatting Property

vcl-cxgridcustomtableview-dot-tcxcustomgridtableview-5fc0a8a8.md

latest5.5 KB
Original Source

TcxCustomGridTableView.ConditionalFormatting Property

Provides access to the conditional formatting controller.

Declaration

delphi
property ConditionalFormatting: TcxDataControllerConditionalFormatting read;

Property Value

TypeDescription
TcxDataControllerConditionalFormatting

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:

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

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:

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
  }

See Also

TcxCustomTreeList.ConditionalFormatting Property

TcxCustomVerticalGrid.ConditionalFormatting Property

TdxSpreadSheetTableView.ConditionalFormatting Property

TcxCustomGridTableView Class

TcxCustomGridTableView Members

cxGridCustomTableView Unit