Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

DataValidationCollection.Add(CellRange, DataValidationType, ValueObject) Method

Creates a new data validation entry and adds it to the document’s collection.

Namespace: DevExpress.Spreadsheet

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

Declaration

DataValidation Add(
    CellRange range,
    DataValidationType validationType,
    ValueObject criteria
)

Parameters

Name Type Description
range CellRange

A CellRange object that is the worksheet range to which the data validation rule is applied.

validationType DataValidationType

A DataValidationType enumeration member that specifies the validation type.

criteria ValueObject

A ValueObject that is the value used in the criterion.

Returns

Type Description
DataValidation

A DataValidation object that specifies a validation rule for a worksheet range.

Remarks

This method overload is used for validation types DataValidationType.Custom and DataValidationType.List.

For the DataValidationType.Custom type, the criteria is a string which can be recognized as a worksheet formula. Therefore, it must begin with an equal sign and evaluate to either true or false.

Note

An individual worksheet cell can have only one data validation rule associated with it. If subsequent Add method calls affect the same cell, only the data validation rule created in the last call is applied.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(CellRange, DataValidationType, ValueObject) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also