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

DataValidation.Criteria2 Property

Gets or sets the value used in the criterion for the data validation.

Namespace: DevExpress.Spreadsheet

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

Declaration

ValueObject Criteria2 { get; set; }

Property Value

Type Description
ValueObject

A ValueObject instance.

Remarks

The Criteria2 value is used only as one of the bounds for DataValidationOperator.Between and DataValidationOperator.NotBetween operators. For other types, you can set the Criteria2 to ValueObject.Empty or simply omit the corresponding parameter when creating the data validation entry via the DataValidationCollection.Add method.

The content specified by the Criteria2 property can be a formula, a constant, a worksheet cell or range.

Since the ValueObject class provides implicit constructors for most types, you can assign a numerical, text, boolean or DateTime value directly to the Criteria2 property. For the worksheet range or formula, use the ValueObject.FromRange or ValueObject.FromFormula methods, respectively.

Example

workbook.LoadDocument("Documents\\DataValidation.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

// Restrict data entry to a number within limits.
DataValidation validation = worksheet.DataValidations.Add(worksheet["F4:F11"], DataValidationType.Decimal, DataValidationOperator.Between, 10, 40);

// Change the validation operator and criteria.
// Range F4:F11 should contain numbers greater than or equal 20.
validation.Operator = DataValidationOperator.GreaterThanOrEqual;
validation.Criteria = 20;
validation.Criteria2 = ValueObject.Empty;

// Highlight data validation ranges.
int[] MyColorScheme = new int[] { 0xFFC4C4, 0xFFD9D9, 0xFFF6F6, 0xFFECEC, 0xE9D3D3 };
for (int i = 0; i < worksheet.DataValidations.Count; i++)
{
    worksheet.DataValidations[i].Range.FillColor = Color.FromArgb(MyColorScheme[i]);
}
See Also