Back to Devexpress

FormatConditionRuleDataUpdate Class

windowsforms-devexpress-dot-xtraeditors-8c91aedd.md

latest10.4 KB
Original Source

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 Data Grid’s GridView, BandedGridView and AdvBandedGridView.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public class FormatConditionRuleDataUpdate :
    FormatConditionRuleAppearanceBase,
    IFormatRuleContextImage
vb
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’s GridView, BandedGridView and AdvBandedGridView.

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 Data Grid’s GridView, BandedGridView and AdvBandedGridView.

Note

The FormatConditionRuleDataUpdate format is not in effect in the following case:

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.

csharp
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);
vb
Dim gridFormatRule As New DevExpress.XtraGrid.GridFormatRule()
Dim formatConditionRuleDataUpdate As 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 = XtraEditors.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%.

csharp
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;
}
vb
Dim gridFormatRule As New DevExpress.XtraGrid.GridFormatRule()
Dim formatConditionRuleDataUpdate As 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)

AddHandler GridView1.FormatRuleDataUpdateCustomTrigger, AddressOf GridView1_FormatRuleDataUpdateCustomTrigger
'...

Private Sub GridView1_FormatRuleDataUpdateCustomTrigger(sender As Object, e As DevExpress.XtraGrid.Views.Grid.FormatRuleGridDataUpdateTriggerEventArgs)
    If e.Rule.Name <> "priceUp" Then Return
    Dim oldVal As Double = Convert.ToDouble(e.OldValue)
    Dim newVal As Double = Convert.ToDouble(e.NewValue)
    Dim diff As Double = (newVal - oldVal) / oldVal
    e.Trigger = diff > 0.05
End Sub

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

Object FormatConditionRuleBase FormatConditionRuleAppearanceBase FormatConditionRuleDataUpdate

See Also

FormatConditionRuleDataUpdate Members

Appearance and Conditional Formatting

DevExpress.XtraEditors Namespace