corelibraries-devexpress-dot-export-dot-xl-dot-xldatavalidation-dot-criteria2.md
Gets or sets the value used in the criterion for data validation.
Namespace : DevExpress.Export.Xl
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public XlValueObject Criteria2 { get; set; }
Public Property Criteria2 As XlValueObject
| Type | Description |
|---|---|
| XlValueObject |
A DevExpress.Export.Xl.XlValueObject object.
|
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);
' 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