All docs
V19.2
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

FormatCondition Class

Represents a conditional format based on a formula.

Namespace: DevExpress.UI.Xaml.Grid

Assembly: DevExpress.UI.Xaml.Grid.v19.2.dll

Declaration

[ContentProperty(Name = "Format")]
public class FormatCondition :
    FormatConditionBase
<ContentProperty(Name:="Format")>
Public Class FormatCondition
    Inherits FormatConditionBase

Remarks

This conditional format allows you to format cells based on comparison of cell values.

The image below shows a grid column whose Profit cells are green if their values are positive.

To create this conditional format in code, create the FormatCondition class instance and specify the following settings:

  • Specify the comparison logic in one of the following ways:

    • Specify the ValueRule, Value1 (and Value2 for Between rule) properties to define how cell values should be compared to boundary value(s).
    • Specify the custom expression by setting the Expression property.
  • Use the FieldName property to specify the column's field name to which to apply the conditional format.
  • Specify the target cells' formatting in one of the following ways:

  • Add the resulting FormatCondition instance to the GridControl.FormatConditions collection.

The XAML snippet below illustrates how to change the font color to green for positive values in the Profit column.

<Grid:GridControl.FormatConditions>
    <Grid:FormatCondition FieldName="Profit" Expression="[Profit] &gt;= 0" 
                          PredefinedFormatName="{x:Bind Grid:PredefinedFormatNames.GreenText}"/>
</Grid:GridControl.FormatConditions>

The code sample below illustrates how to define the same conditional format in code-behind.

  var profitFormatCondition = new FormatCondition() {
      FieldName = "Profit",
      Expression = "[Profit] > 0",
      PredefinedFormatName = "GreenText"
  };
  gridControl.FormatConditions.Add(profitFormatCondition);

Inheritance

See Also