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.AddTimePeriodConditionalFormatting(CellRange, ConditionalFormattingTimePeriod) Method

Applies a "date occurring..." conditional formatting rule.

Namespace: DevExpress.Spreadsheet

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

Declaration

TimePeriodConditionalFormatting AddTimePeriodConditionalFormatting(
    CellRange range,
    ConditionalFormattingTimePeriod timePeriod
)
Function AddTimePeriodConditionalFormatting(
    range As CellRange,
    timePeriod As ConditionalFormattingTimePeriod
) As TimePeriodConditionalFormatting
TimePeriodConditionalFormatting AddTimePeriodConditionalFormatting(
    CellRange range,
    ConditionalFormattingTimePeriod timePeriod
)
Function AddTimePeriodConditionalFormatting(
    range As CellRange,
    timePeriod As ConditionalFormattingTimePeriod
) As TimePeriodConditionalFormatting
TimePeriodConditionalFormatting AddTimePeriodConditionalFormatting(
    CellRange range,
    ConditionalFormattingTimePeriod timePeriod
)
Function AddTimePeriodConditionalFormatting(
    range As CellRange,
    timePeriod As ConditionalFormattingTimePeriod
) As TimePeriodConditionalFormatting

Parameters

Name Type Description
range CellRange

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

timePeriod ConditionalFormattingTimePeriod

One of the ConditionalFormattingTimePeriod enumeration values specifying time periods to be highlighted in a range of cells.

Parameters

Name Type Description
range CellRange

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

timePeriod ConditionalFormattingTimePeriod

One of the ConditionalFormattingTimePeriod enumeration values specifying time periods to be highlighted in a range of cells.

Parameters

Name Type Description
range CellRange

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

timePeriod ConditionalFormattingTimePeriod

One of the ConditionalFormattingTimePeriod enumeration values specifying time periods to be highlighted in a range of cells.

Returns

Type Description
TimePeriodConditionalFormatting

A TimePeriodConditionalFormatting object that represents the specified conditional format.

Returns

Type Description
TimePeriodConditionalFormatting

A TimePeriodConditionalFormatting object that represents the specified conditional format.

Returns

Type Description
TimePeriodConditionalFormatting

A TimePeriodConditionalFormatting object that represents the specified conditional format.

Examples

This example demonstrates how to apply a "date occurring..." conditional formatting rule.

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

    • A CellRange object that defines a range of cells to which the rule is applied.
    • A time period to be highlighted. This parameter is specified by one of the ConditionalFormattingTimePeriod enumeration values.
  2. Specify formatting options to be applied to cells if the condition is true using the ISupportsFormatting.Formatting property of the TimePeriodConditionalFormatting object.

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

' Create the rule to highlight today's dates in cells B2 through B6.
Dim cfRule As TimePeriodConditionalFormatting = worksheet.ConditionalFormattings.AddTimePeriodConditionalFormatting(worksheet.Range("$B$2:$B$6"), ConditionalFormattingTimePeriod.Today)
' Specify formatting options to be applied to cells if the condition is true.
' Set the background color to pink.
cfRule.Formatting.Fill.BackgroundColor = Color.FromArgb(255, &HF2, &HAE, &HE3)
See Also