Skip to main content

XlDataValidation.Operator Property

Gets or sets the relational operator used in the data validation rule.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v24.1.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public XlDataValidationOperator Operator { get; set; }

Property Value

Type Description
XlDataValidationOperator

A XlDataValidationOperator enumeration values that specifies the relational operator.

Available values:

Name Description
Between

Checks whether the cell value falls within a specified range of values.

NotBetween

Checks whether the cell value does not fall with a specified range of values.

Equal

Checks whether the cell value equals a specified value.

NotEqual

Checks whether the cell value is not equal to a specified value.

LessThan

Checks whether the cell value is less than a specified value.

LessThanOrEqual

Checks whether the cell values is less than or equal to a specified value.

GreaterThan

Checks whether the cell value is greater than a specified value.

GreaterThanOrEqual

Checks whether the cell value is greater than or equal to a specified value.

Remarks

Use the XlDataValidation.Criteria1 and the XlDataValidation.Criteria2 (if the validation rule requires two values) properties to provide the criterion values.

The code sample below shows how to use an operator to create a data validation rule:

// 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