The requested page is not available for the requested platform. You are viewing the content for Default platform.

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; }
<XtraSerializableProperty>
Public Property ValueRule As ConditionRule

Property Value

Type Description
ConditionRule

A ConditionRule enumeration value.

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.

Examples

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