All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

ConditionalFormattingCollection.AddSpecialConditionalFormatting(CellRange, ConditionalFormattingSpecialCondition) Method

Applies the conditional formatting rule that formats cells which contain the specified values (unique or duplicate values, formula errors, etc.).

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v21.1.Core.dll

Declaration

SpecialConditionalFormatting AddSpecialConditionalFormatting(
    CellRange range,
    ConditionalFormattingSpecialCondition condition
)

Parameters

Name Type Description
range CellRange

A CellRange object that specifies a range of cells to which the conditional formatting rule is applied.

condition ConditionalFormattingSpecialCondition

One of the ConditionalFormattingSpecialCondition enumeration values.

Returns

Type Description
SpecialConditionalFormatting

A SpecialConditionalFormatting object that represents the specified conditional format.

Example

This example demonstrates how to specify the rule that highlights unique or duplicate values, formula errors, etc.

  1. To create a new conditional formatting rule represented by the SpecialConditionalFormatting object, access the collection of conditional formats from the Worksheet.ConditionalFormattings property and call the ConditionalFormattingCollection.AddSpecialConditionalFormatting method. Pass the following parameters:

  2. Specify formatting options to be applied to cells if the condition is true, using the ISupportsFormatting.Formatting property of the SpecialConditionalFormatting object.

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

' Create the rule to identify unique values in cells A2 through A15. 
Dim cfRule As SpecialConditionalFormatting = worksheet.ConditionalFormattings.AddSpecialConditionalFormatting(worksheet.Range("$A$2:$A$15"), ConditionalFormattingSpecialCondition.ContainUniqueValue)
' Specify formatting options to be applied to cells if the condition is true.
' Set the background color to yellow.
cfRule.Formatting.Fill.BackgroundColor = Color.FromArgb(255, &HFA, &HF7, &HAA)
See Also