Back to Devexpress

DataValidationType Enum

officefileapi-devexpress-dot-spreadsheet-67b5a9f3.md

latest3.9 KB
Original Source

DataValidationType Enum

Lists data validation types.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public enum DataValidationType
vb
Public Enum DataValidationType

Members

NameDescription
AnyValue

Any value satisfies validation criteria, equivalent to no validation.

| | WholeNumber |

Checks for whole numeric values satisfying given conditions.

| | Decimal |

Checks for decimal values satisfying the given condition.

| | List |

Checks whether a value matches a specified list of values. The maximum length of a list is 255 characters.

| | Date |

Checks for date values satisfying the given condition.

| | Time |

Checks for time values satisfying the given condition.

| | TextLength |

Checks for text values whose length satisfies the given condition.

| | Custom |

Data is validated using an arbitrary formula.

|

The following properties accept/return DataValidationType values:

Remarks

Use the DataValidationCollection.Add method to create a data validation of the required type. The DataValidation.ValidationType property obtains the type of the data validation. This property is read-only, because the data validation type is specified when the data validation entry is created, and cannot be changed.

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

See Also

DevExpress.Spreadsheet Namespace