.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

ColorScale3ConditionalFormatting Interface

Represents a three-color scale conditional formatting rule.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.2.Core.dll

Declaration

public interface ColorScale3ConditionalFormatting :
    ColorScale2ConditionalFormatting,
    ConditionalFormatting
Public Interface ColorScale3ConditionalFormatting
    Inherits ColorScale2ConditionalFormatting,
             ConditionalFormatting
public interface ColorScale3ConditionalFormatting :
    ColorScale2ConditionalFormatting,
    ConditionalFormatting
Public Interface ColorScale3ConditionalFormatting
    Inherits ColorScale2ConditionalFormatting,
             ConditionalFormatting
public interface ColorScale3ConditionalFormatting :
    ColorScale2ConditionalFormatting,
    ConditionalFormatting
Public Interface ColorScale3ConditionalFormatting
    Inherits ColorScale2ConditionalFormatting,
             ConditionalFormatting

Remarks

The conditional formatting rule, which is specified by the ColorScale3ConditionalFormatting object, differentiates high, medium, and low values in the range of cell values using a color scale. The Worksheet.ConditionalFormattings property returns the ConditionalFormattingCollection collection that stores all conditional formatting rules specified on a worksheet. Use the methods of the ConditionalFormattingCollection object to apply (the ConditionalFormattingCollection.AddColorScale3ConditionalFormatting method) or remove (the ConditionalFormattingCollection.Remove method) the conditional format.

Examples

This example demonstrates how to apply a three-color scale conditional formatting rule.

  1. First of all, specify the minimum, midpoint and maximum thresholds of a range to which the rule will be applied. Threshold values are determined by the ConditionalFormattingValue object that can be accessed via the ConditionalFormattingCollection.CreateValue method. The type of the threshold value is specified by one of the ConditionalFormattingValueType enumeration values and can be a number, percent, formula, or percentile. Call the ConditionalFormattingCollection.CreateValue method with the ConditionalFormattingValueType.MinMax parameter to set the minimum and maximum thresholds to the lowest and highest values in a range of cells, respectively.
  2. To apply a conditional formatting rule represented by the ColorScale3ConditionalFormatting object, access the collection of conditional formats from the Worksheet.ConditionalFormattings property and call the ConditionalFormattingCollection.AddColorScale3ConditionalFormatting method with the following parameters:

    • A CellRange object that defines a range of cells to which the rule is applied.
    • A minimum threshold specified by the ConditionalFormattingValue object.
    • A color corresponding to the minimum value in a range of cells.
    • A midpoint threshold specified by the ConditionalFormattingValue object.
    • A color corresponding to the middle value in a range of cells.
    • A maximum threshold specified by the ConditionalFormattingValue object.
    • A color corresponding to the maximum value in a range of cells.

To remove the ColorScale3ConditionalFormatting object, use the ConditionalFormattingCollection.Remove, ConditionalFormattingCollection.RemoveAt or ConditionalFormattingCollection.Clear methods.

Dim conditionalFormattings As ConditionalFormattingCollection = worksheet.ConditionalFormattings
' Set the minimum threshold to the lowest value in the range of cells using the MIN() formula.
    Dim minPoint As ConditionalFormattingValue = conditionalFormattings.CreateValue(ConditionalFormattingValueType.Formula, "=MIN($C$2:$D$15)")
' Set the midpoint threshold to the 50th percentile.
    Dim midPoint As ConditionalFormattingValue = conditionalFormattings.CreateValue(ConditionalFormattingValueType.Percentile, "50")
' Set the maximum threshold to the highest value in the range of cells using the MAX() formula.
    Dim maxPoint As ConditionalFormattingValue = conditionalFormattings.CreateValue(ConditionalFormattingValueType.Number, "=MAX($C$2:$D$15)")
' Create the three-color scale rule to determine how values in cells C2 through D15 vary. Red represents the lower values, yellow represents the medium values and sky blue represents the higher values.
Dim cfRule As ColorScale3ConditionalFormatting = conditionalFormattings.AddColorScale3ConditionalFormatting(worksheet.Range("$C$2:$D$15"), minPoint, Color.Red, midPoint, Color.Yellow, maxPoint, Color.SkyBlue)
See Also