Back to Devexpress

XlDataValidation.Criteria2 Property

corelibraries-devexpress-dot-export-dot-xl-dot-xldatavalidation-dot-criteria2.md

latest3.2 KB
Original Source

XlDataValidation.Criteria2 Property

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

Declaration

csharp
public XlValueObject Criteria2 { get; set; }
vb
Public Property Criteria2 As XlValueObject

Property Value

TypeDescription
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.

csharp
// 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);
vb
' 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

XlDataValidation Class

XlDataValidation Members

DevExpress.Export.Xl Namespace