All docs
V19.2
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+
.NET Core 3.0+
Row

ConditionalFormattingCollection.AddFormulaExpressionConditionalFormatting(CellRange, String) Method

Applies the conditional formatting rule that uses a formula to determine which cells to format.

Namespace: DevExpress.Spreadsheet

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

Declaration

FormulaExpressionConditionalFormatting AddFormulaExpressionConditionalFormatting(
    CellRange range,
    string expression
)
Function AddFormulaExpressionConditionalFormatting(
    range As CellRange,
    expression As String
) As FormulaExpressionConditionalFormatting
FormulaExpressionConditionalFormatting AddFormulaExpressionConditionalFormatting(
    CellRange range,
    string expression
)
Function AddFormulaExpressionConditionalFormatting(
    range As CellRange,
    expression As String
) As FormulaExpressionConditionalFormatting
FormulaExpressionConditionalFormatting AddFormulaExpressionConditionalFormatting(
    CellRange range,
    string expression
)
Function AddFormulaExpressionConditionalFormatting(
    range As CellRange,
    expression As String
) As FormulaExpressionConditionalFormatting

Parameters

Name Type Description
range CellRange

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

expression String

A String value that represents a formula in the invariant culture to be used as a formatting criteria. Start the formula with an equal sign (=). The formula can include the spreadsheet's built-in functions. You can combine relative and absolute references to adjust the formula in each cell if necessary.

Parameters

Name Type Description
range CellRange

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

expression String

A String value that represents a formula in the invariant culture to be used as a formatting criteria. Start the formula with an equal sign (=). The formula can include the spreadsheet's built-in functions. You can combine relative and absolute references to adjust the formula in each cell if necessary.

Parameters

Name Type Description
range CellRange

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

expression String

A String value that represents a formula in the invariant culture to be used as a formatting criteria. Start the formula with an equal sign (=). The formula can include the spreadsheet's built-in functions. You can combine relative and absolute references to adjust the formula in each cell if necessary.

Returns

Type Description
FormulaExpressionConditionalFormatting

A FormulaExpressionConditionalFormatting object that represents the specified conditional format.

Returns

Type Description
FormulaExpressionConditionalFormatting

A FormulaExpressionConditionalFormatting object that represents the specified conditional format.

Returns

Type Description
FormulaExpressionConditionalFormatting

A FormulaExpressionConditionalFormatting object that represents the specified conditional format.

Examples

This example demonstrates how to create the rule that uses a formula as a criterion to apply a conditional format.

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

    • A CellRange object that defines a range of cells to which the rule is applied.
    • A string value that determines a formula to evaluate.
  2. Specify formatting options to be applied to cells if the condition is true, using the ISupportsFormatting.Formatting property of the FormulaExpressionConditionalFormatting object.

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

' Create the rule to shade alternate rows without applying a new style.
Dim cfRule As FormulaExpressionConditionalFormatting = worksheet.ConditionalFormattings.AddFormulaExpressionConditionalFormatting(worksheet.Range("$A$2:$G$15"), "=MOD(ROW(),2)=1")
' Specify formatting options to be applied to cells if the condition is true.
' Set the background color to light blue.
cfRule.Formatting.Fill.BackgroundColor = Color.FromArgb(255, &HBC, &HDA, &HF7)
See Also