Skip to main content

FormatCondition.ValueRule Property

Specifies the rule for conditional formatting. This is a bindable property.

Namespace: DevExpress.Mobile.DataGrid

Assembly: DevExpress.Mobile.Grid.v18.2.dll

Declaration

[XtraSerializableProperty]
public ConditionRule ValueRule { get; set; }

Property Value

Type Description
ConditionRule

A ConditionRule enumeration value.

Available values:

Name Description
None

The format is applied to all cells of the target column.

Equal

The format is applied to cells whose values match the FormatCondition.Value1 property value.

NotEqual

The format is applied to cells whose values do not match the FormatCondition.Value1 property value.

Between

The format is applied to cells whose values fall into the range specified by the FormatCondition.Value1 and FormatCondition.Value2 properties.

NotBetween

The format is applied to cells whose values fall outside of the range specified by the FormatCondition.Value1 and FormatCondition.Value2 properties.

Less

The format is applied to cells whose values are less than the FormatCondition.Value1 property value.

Greater

The format is applied to cells whose values are greater than the FormatCondition.Value1 property value.

GreaterOrEqual

The format is applied to cells whose values are greater or equal to the FormatCondition.Value1 property value.

LessOrEqual

The format is applied to cells whose values are less or equal to the FormatCondition.Value1 property value.

Expression

The format is applied to cells for which the ExpressionConditionBase.Expression evaluates to true.

Remarks

Important

This documentation topic describes legacy technology. We no longer develop new functionality for the GridControl and suggest that you use the new DataGridView control instead.

The ValueRule property specifies how cell values should be compared to the FormatCondition.Value1 and FormatCondition.Value2 property values in order to determine whether the conditional format should be applied to them.

If the ValueRule property is set to ConditionRule.None, the format is applied to all cells of the target column.

The ValueRule property’s default value is ConditionRule.Expression. In this case, a custom rule to format cells is specified by the ExpressionConditionBase.Expression property.

Example

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.

ConditionalFormatting_Condition

  1. Create a new FormatCondition class instance.
  2. 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.
  3. Assign one of the predefined formats to the FormatConditionBase.PredefinedFormatName property. All available format names are listed in the Predefined Format Names document.
  4. Specify the comparison operator by setting the FormatCondition.ValueRule property. In this example, the Less operator is used for constructing the rule’s criteria.
  5. Set the FormatCondition.Value1 property to 0.20. This means that the format should be applied to cells with market share less than 20%.
  6. To apply a conditional formatting rule represented by the created FormatCondition object, add this object to the GridControl.FormatConditions collection.
using DevExpress.Mobile.DataGrid;
using DevExpress.Mobile.Core.ConditionalFormatting;
// ...

FormatCondition condition = new FormatCondition ();
condition.FieldName = "MarketShare";
condition.PredefinedFormatName = "RedText";
condition.ValueRule = ConditionRule.Less;
condition.Value1 = 0.20;

grid.FormatConditions.Add (condition);
See Also