FormatConditionRuleDataUpdate Class

Highlights a cell with a custom icon and/or appearance settings for a limited time when a cell value changes. This format is only supported in the Data Grid control.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

public class FormatConditionRuleDataUpdate :
    FormatConditionRuleAppearanceBase,
    IFormatRuleContextImage
Public Class FormatConditionRuleDataUpdate
    Inherits FormatConditionRuleAppearanceBase
    Implements IFormatRuleContextImage

Remarks

The FormatConditionRuleDataUpdate format allows you to temporarily highlight cells (with icons and/or customized appearance settings) when cell values change, increase or decrease. You can also implement a custom trigger with the GridView.FormatRuleDataUpdateCustomTrigger event.

NOTE

Currently this format is only supported in the Data Grid control.

The following are the main properties the FormatConditionRuleDataUpdate format provides.

Use the following properties to set the format's icon and/or color.

  • Appearance - Allows you to explicitly set the appearance settings (background and foreground colors and font settings) for target cells. This property's settings take priority over the style specified by the FormatConditionRuleAppearanceBase.PredefinedName property.
  • PredefinedName - Gets or sets the name of a predefined or custom style applied to target cells.
  • Icon - Allows you to display a custom image or a predefined icon.
  • AllowAnimation - Gets or sets whether the format is repainted with an animation effect when a cell value changes. Animation effects are supported for specific format rules, only in the Data Grid control.

Example

This example uses a FormatConditionRuleDataUpdate format to temporarily highlight cells when their values increase. The highlight effect includes a custom background color and icon.

XtraGrid.GridFormatRule gridFormatRule = new DevExpress.XtraGrid.GridFormatRule();
DevExpress.XtraEditors.FormatConditionRuleDataUpdate formatConditionRuleDataUpdate = new DevExpress.XtraEditors.FormatConditionRuleDataUpdate();
gridFormatRule.Column = gridView1.Columns["Change"];
gridFormatRule.Name = "Format1";
formatConditionRuleDataUpdate.HighlightTime = 500;
formatConditionRuleDataUpdate.Icon.PredefinedName = "Flags3_1.png";
formatConditionRuleDataUpdate.PredefinedName = "Green Fill";
formatConditionRuleDataUpdate.Trigger = FormatConditionDataUpdateTrigger.ValueIncreased;
gridFormatRule.Rule = formatConditionRuleDataUpdate;
gridView1.FormatRules.Add(gridFormatRule);

Example

The following example creates a FormatConditionRuleDataUpdate format that temporarily highlights a Data Grid cell in the Price column when a cell value is increased by 5%.

DevExpress.XtraGrid.GridFormatRule gridFormatRule = new DevExpress.XtraGrid.GridFormatRule();
DevExpress.XtraEditors.FormatConditionRuleDataUpdate formatConditionRuleDataUpdate = new DevExpress.XtraEditors.FormatConditionRuleDataUpdate();
gridFormatRule.Column = gridView1.Columns["Price"];
gridFormatRule.Name = "priceUp";
formatConditionRuleDataUpdate.HighlightTime = 800;
formatConditionRuleDataUpdate.PredefinedName = "Green Fill, Green Text";
formatConditionRuleDataUpdate.Trigger = DevExpress.XtraEditors.FormatConditionDataUpdateTrigger.Custom;
gridFormatRule.Rule = formatConditionRuleDataUpdate;
gridView1.FormatRules.Add(gridFormatRule);

gridView1.FormatRuleDataUpdateCustomTrigger += gridView1_FormatRuleDataUpdateCustomTrigger;
//...

private void gridView1_FormatRuleDataUpdateCustomTrigger(object sender, Views.Grid.FormatRuleGridDataUpdateTriggerEventArgs e) {
    if (e.Rule.Name != "priceUp") return;
    double oldVal = Convert.ToDouble(e.OldValue);
    double newVal = Convert.ToDouble(e.NewValue);
    double diff = (newVal - oldVal) / oldVal;
    e.Trigger = diff > 0.05;
}

Create format rules at design time

The Data Grid control provides a Designer that helps you create format conditions, including the FormatConditionRuleDataUpdate format at design time.

Create format rules at runtime

End-users can create and modify FormatConditionRuleDataUpdate formats at runtime provided that the ShowConditionalFormattingItem option is enabled (see GridOptionsMenu.ShowConditionalFormattingItem and TreeListOptionsMenu.ShowConditionalFormattingItem). End-users can invoke a format condition editor from a column header's context menu.

NOTE

To visualize changes to cell values, you can also use animated conditional formats. When a cell value changes, the format rule is repainted with an animation effect (a fade effect, progressively filled data bar, etc.). See the FormatConditionRuleBase.AllowAnimation property for information on the formats that support animation effects. All formats except the FormatConditionRuleDataUpdate remain visible until specific criteria are met.

Inheritance

See Also