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

ExpressionConditionBase.Expression Property

Gets or sets the expression specifying to which cells the format should be applied. This is a bindable property.

Namespace: DevExpress.Mobile.DataGrid

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

Declaration

[XtraSerializableProperty]
public string Expression { get; set; }
<XtraSerializableProperty>
Public Property Expression As String

Property Value

Type Description
String

A String value that specifies the expression used to apply the conditional formatting rule.

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.

If a cell value meets the expression set to the Expression property, the format is applied to a target cell(s).

Examples

This example illustrates how to apply a format to rows in a GridControl that match a specific expression.

ConditionalFormatting_Expression

An expression is a string that, when parsed and processed, evaluates some value. Expressions consist of column names, constants, operators, and functions. In this example, a Boolean expression is used. If the expression evaluates to true, the format is applied. The format highlights rows that have values in the Total column that are less than 100.

  1. Create a new FormatCondition class instance.
  2. Set this object's FormatConditionBase.FieldName property to Total. This column provides values to test against the formatting rule.
  3. Assign the expression string to the ExpressionConditionBase.Expression property.
  4. Assign one of the predefined formats to the FormatConditionBase.PredefinedFormatName property. All available format names are listed in the Predefined Format Names document.
  5. Set the ExpressionConditionBase.ApplyToRow property to true to apply the format to entire rows instead of individual column cells.
  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;
// ...

FormatCondition condition = new FormatCondition();
condition.FieldName = "Total";
condition.Expression = "[Total] < 100";
condition.PredefinedFormatName = "LightRedFillWithDarkRedText";
condition.ApplyToRow = true;

grid.FormatConditions.Add (condition);
See Also