Back to Devexpress

XlDataValidation.Ranges Property

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

latest2.3 KB
Original Source

XlDataValidation.Ranges Property

Provides access to the collection of cell ranges to which the data validation rule is applied.

Namespace : DevExpress.Export.Xl

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

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public IList<XlCellRange> Ranges { get; }
vb
Public ReadOnly Property Ranges As IList(Of XlCellRange)

Property Value

TypeDescription
IList<XlCellRange>

A IList<XlCellRange> object representing the list of cell ranges.

|

Remarks

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

csharp
// Apply data validation to cells.
// Restrict data entry in the range A2:A5 to a 5-digit number.
XlDataValidation validation = new XlDataValidation();
validation.Ranges.Add(XlCellRange.FromLTRB(0, 1, 0, 4));
validation.Type = XlDataValidationType.Custom;
validation.Criteria1 = "=AND(ISNUMBER(A2),LEN(A2)=5)";
// Add the specified rule to the worksheet collection of data validation rules.
sheet.DataValidations.Add(validation);
vb
' Apply data validation to cells.
' Restrict data entry in the range A2:A5 to a 5-digit number.
Dim validation As New XlDataValidation()
validation.Ranges.Add(XlCellRange.FromLTRB(0, 1, 0, 4))
validation.Type = XlDataValidationType.Custom
validation.Criteria1 = "=AND(ISNUMBER(A2),LEN(A2)=5)"
' 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