TopBottomRuleFormatCondition.Rule Property
Specifies the rule for the top/bottom conditional formatting. This is a bindable property.
Namespace: DevExpress.Mobile.DataGrid
Assembly: DevExpress.Mobile.Grid.v18.2.dll
Declaration
Property Value
Type | Description |
---|---|
TopBottomRule | A TopBottomRule enumeration value. |
Available values:
Name | Description |
---|---|
TopItems | The format is applied to cells whose values are the largest for the field. The number of cells is specified by the TopBottomRuleFormatCondition.Threshold property. |
TopPercent | The format is applied to cells whose values are the largest for the field. The percentage of cells is specified by the TopBottomRuleFormatCondition.Threshold property. |
BottomItems | The format is applied to cells whose values are the lowest for the field. The number of cells is specified by the TopBottomRuleFormatCondition.Threshold property. |
BottomPercent | The format is applied to cells whose values are the lowest for the field. The percentage of cells is specified by the TopBottomRuleFormatCondition.Threshold property. |
AboveAverage | The format is applied to cells whose values are above the average value for the field. |
BelowAverage | The format is applied to cells whose values are below the average value for the field. |
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 Rule property is used to set a top/bottom rule that specifies which cells (or corresponding rows) should be formatted.
Example
This example illustrates how to apply a top/bottom format to the Total column in a GridControl. The top/bottom format allows you to find the highest or lowest cell values. In this tutorial, the five top values in the Total column are highlighted.
- Create a new TopBottomRuleFormatCondition class instance.
- Set this object’s FormatConditionBase.FieldName property to Total. This column provides values to test against the formatting rule and the specified format will be applied to this column.
- Set the
TopBottomRuleFormatCondition.Rule
property to TopBottomRule.TopItems to highlight the highest column values. - Use the TopBottomRuleFormatCondition.Threshold property to specify the count of column cells with highest values to be highlighted.
- Assign one of the predefined formats to the FormatConditionBase.PredefinedFormatName property. All available format names are listed in the Predefined Format Names document.
- To apply a conditional formatting rule represented by the created TopBottomRuleFormatCondition object, add this object to the GridControl.FormatConditions collection.
using DevExpress.Mobile.DataGrid;
using DevExpress.Mobile.Core.ConditionalFormatting;
// ...
TopBottomRuleFormatCondition condition = new TopBottomRuleFormatCondition();
condition.FieldName = "Total";
condition.Rule = TopBottomRule.TopItems;
condition.Threshold = 5;
condition.PredefinedFormatName = "GreenFillWithDarkGreenText";
grid.FormatConditions.Add (condition);