Back to Devexpress

XlDataValidation.Operator Property

corelibraries-devexpress-dot-export-dot-xl-dot-xldatavalidation-52be974c.md

latest4.1 KB
Original Source

XlDataValidation.Operator Property

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

Namespace : DevExpress.Export.Xl

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

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public XlDataValidationOperator Operator { get; set; }
vb
Public Property [Operator] As XlDataValidationOperator

Property Value

TypeDescription
XlDataValidationOperator

A XlDataValidationOperator enumeration values that specifies the relational operator.

|

Available values:

NameDescription
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:

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