Back to Devexpress

DataValidation.Operator Property

officefileapi-devexpress-dot-spreadsheet-dot-datavalidation-f51c0f15.md

latest6.8 KB
Original Source

DataValidation.Operator Property

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

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
DataValidationOperator Operator { get; set; }
vb
Property [Operator] As DataValidationOperator

Property Value

TypeDescription
DataValidationOperator

A DataValidationOperator used in rule definition.

|

Available values:

NameDescription
Between

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

| | NotBetween |

Determines whether the cell value does not fall within a specified range of values.

| | Equal |

Determines whether the cell value equals a specified value.

| | NotEqual |

Determines whether the cell value does not equal the specified value.

| | LessThan |

Determines whether the cell value is less than the specified value.

| | LessThanOrEqual |

Determines whether the cell value is less than or equal to the specified value.

| | GreaterThan |

Determines whether the cell value is greater than the specified value.

| | GreaterThanOrEqual |

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

|

Example

View Example

csharp
workbook.LoadDocument("Documents\\DataValidation.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

// Restrict data entry to a number within limits.
DataValidation validation = worksheet.DataValidations.Add(worksheet["F4:F11"], DataValidationType.Decimal, DataValidationOperator.Between, 10, 40);

// Change the validation operator and criteria.
// Range F4:F11 should contain numbers greater than or equal 20.
validation.Operator = DataValidationOperator.GreaterThanOrEqual;
validation.Criteria = 20;
validation.Criteria2 = ValueObject.Empty;

// Highlight data validation ranges.
int[] MyColorScheme = new int[] { 0xFFC4C4, 0xFFD9D9, 0xFFF6F6, 0xFFECEC, 0xE9D3D3 };
for (int i = 0; i < worksheet.DataValidations.Count; i++)
{
    worksheet.DataValidations[i].Range.FillColor = Color.FromArgb(MyColorScheme[i]);
}
vb
workbook.LoadDocument("Documents\DataValidation.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)

' Restrict data entry to a number within limits.
Dim validation As DataValidation = worksheet.DataValidations.Add(worksheet("F4:F11"), DataValidationType.Decimal, DataValidationOperator.Between, 10, 40)

' Change the validation operator and criteria.
' Range F4:F11 should contain numbers greater than or equal 20.
validation.Operator = DataValidationOperator.GreaterThanOrEqual
validation.Criteria = 20
validation.Criteria2 = ValueObject.Empty

' Highlight data validation ranges.
Dim MyColorScheme() As Integer = { &HFFC4C4, &HFFD9D9, &HFFF6F6, &HFFECEC, &HE9D3D3 }
For i As Integer = 0 To worksheet.DataValidations.Count - 1
    worksheet.DataValidations(i).Range.FillColor = Color.FromArgb(MyColorScheme(i))
Next i

The following code snippets (auto-collected from DevExpress Examples) contain references to the Operator property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-spreadsheetcontrol-api-part-3/CS/SpreadsheetControl_API_Part03/CodeExamples/DataValidationActions.cs#L59

csharp
// Range F4:F11 should contain numbers greater than or equal 20.
validation.Operator = DataValidationOperator.GreaterThanOrEqual;
validation.Criteria = 20;

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/DataValidationActions.cs#L71

csharp
// Range F4:F11 should contain numbers greater than or equal 20.
validation.Operator = DataValidationOperator.GreaterThanOrEqual;
validation.Criteria = 20;

spreadsheet-document-api-examples-part2/CS/SpreadsheetDocServerAPIPart2/CodeExamples/DataValidationActions.cs#L82

csharp
// if they are greater than or equal 20.
validation.Operator = DataValidationOperator.GreaterThanOrEqual;
validation.Criteria = 20;

winforms-spreadsheetcontrol-api-part-3/VB/SpreadsheetControl_API_Part03/CodeExamples/DataValidationActions.vb#L49

vb
' Range F4:F11 should contain numbers greater than or equal 20.
validation.[Operator] = DevExpress.Spreadsheet.DataValidationOperator.GreaterThanOrEqual
validation.Criteria = 20

spreadsheet-document-api-examples-part2/VB/SpreadsheetDocServerAPIPart2/CodeExamples/DataValidationActions.vb#L79

vb
' if they are greater than or equal 20.
validation.Operator = DataValidationOperator.GreaterThanOrEqual
validation.Criteria = 20

See Also

DataValidation Interface

DataValidation Members

DevExpress.Spreadsheet Namespace