Skip to main content

XlDataValidation.Criteria2 Property

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

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v23.2.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public XlValueObject Criteria2 { get; set; }

Property Value

Type Description
XlValueObject

A DevExpress.Export.Xl.XlValueObject object.

Remarks

Use this property to set one of the bounds for the XlDataValidationOperator.Between or XlDataValidationOperator.NotBetween operators.

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

// Restrict data entry in the cell range D2:D5 to a decimal number within the specified limits.
// Bonus cannot be greater than 10% of the salary.
validation = new XlDataValidation();
validation.Ranges.Add(XlCellRange.FromLTRB(3, 1, 3, 4));
validation.Type = XlDataValidationType.Decimal;
validation.Operator = XlDataValidationOperator.Between;
validation.Criteria1 = 0;

// Use a formula to specify the validation criterion.
validation.Criteria2 = "=C2*0.1";

// Display the error message.
validation.ErrorMessage = "Bonus cannot be greater than 10% of the salary.";
validation.ErrorTitle = "Information";
validation.ErrorStyle = XlDataValidationErrorStyle.Information;
validation.ShowErrorMessage = true;

// Add the specified rule to the worksheet collection of data validation rules.
sheet.DataValidations.Add(validation);
See Also