Represents a format condition based on a specified rule(s) or expression (equal, less, between, etc.).
public class FormatCondition :
Public Class FormatCondition
This example illustrates how to apply conditional formatting to a Market Share column in a GridControl to highlight cells that match a specific condition. Cells containing values that are less than 20% will be highlighted.
- Create a new FormatCondition class instance.
- Set this object's FormatConditionBase.FieldName property to MarketShare. This column provides values to test against the formatting rule and the specified format will be applied to this column.
- Assign one of the predefined formats to the FormatConditionBase.PredefinedFormatName property. All available format names are listed in the Predefined Format Names document.
- Specify the comparison operator by setting the FormatCondition.ValueRule property. In this example, the Less operator is used for constructing the rule's criteria.
- Set the FormatCondition.Value1 property to 0.20. This means that the format should be applied to cells with market share less than 20%.
- To apply a conditional formatting rule represented by the created FormatCondition object, add this object to the GridControl.FormatConditions collection.
FormatCondition condition = new FormatCondition ();
condition.FieldName = "MarketShare";
condition.PredefinedFormatName = "RedText";
condition.ValueRule = ConditionRule.Less;
condition.Value1 = 0.20;