Class DataValidationsCollection
Class for managing the collection of DataValidation elements.
Inheritance
Namespace: IronXL.DataValidations
Assembly: IronXL.dll
Syntax
public class DataValidationsCollection : Object, IEnumerable<DataValidation>, IEnumerable
Properties
Count
Gets the number of data validation rules in the collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Int32]
Gets the data validation rule at the specified index.
Declaration
public DataValidation this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
DataValidation |
Methods
AddDateRule(Cell, ComparisonOperator, DateTime, Nullable<DateTime>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddDateRule(Cell constrainedCell, ComparisonOperator comparisonOperator, DateTime minValue, Nullable<DateTime> maxValue)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell | The cell to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.DateTime | minValue | The minimum value for the data validation rule. |
System.Nullable<System.DateTime> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddDateRule(Range, ComparisonOperator, DateTime, Nullable<DateTime>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddDateRule(Range constrainedRange, ComparisonOperator comparisonOperator, DateTime minValue, Nullable<DateTime> maxValue)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange | The range to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.DateTime | minValue | The minimum value for the data validation rule. |
System.Nullable<System.DateTime> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddDateRule(RangeAddress, ComparisonOperator, DateTime, Nullable<DateTime>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddDateRule(RangeAddress constrainedRangeAddress, ComparisonOperator comparisonOperator, DateTime minValue, Nullable<DateTime> maxValue)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | constrainedRangeAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.DateTime | minValue | The minimum value for the data validation rule. |
System.Nullable<System.DateTime> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddDateRule(String, ComparisonOperator, DateTime, Nullable<DateTime>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddDateRule(string constrainedAddress, ComparisonOperator comparisonOperator, DateTime minValue, Nullable<DateTime> maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | constrainedAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.DateTime | minValue | The minimum value for the data validation rule. |
System.Nullable<System.DateTime> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddDecimalRule(Cell, ComparisonOperator, Decimal, Nullable<Decimal>)
Adds a new data validation rule with a ConstraintType of Decimal to the worksheet in the specified range.
Declaration
public DataValidation AddDecimalRule(Cell constrainedCell, ComparisonOperator comparisonOperator, Decimal minValue, Nullable<Decimal> maxValue)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell | The cell to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Decimal | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Decimal> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddDecimalRule(Range, ComparisonOperator, Decimal, Nullable<Decimal>)
Adds a new data validation rule with a ConstraintType of Decimal to the worksheet in the specified range.
Declaration
public DataValidation AddDecimalRule(Range constrainedRange, ComparisonOperator comparisonOperator, Decimal minValue, Nullable<Decimal> maxValue)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange | The range to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Decimal | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Decimal> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddDecimalRule(RangeAddress, ComparisonOperator, Decimal, Nullable<Decimal>)
Adds a new data validation rule with a ConstraintType of Decimal to the worksheet in the specified range.
Declaration
public DataValidation AddDecimalRule(RangeAddress constrainedRangeAddress, ComparisonOperator comparisonOperator, Decimal minValue, Nullable<Decimal> maxValue)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | constrainedRangeAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Decimal | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Decimal> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddDecimalRule(String, ComparisonOperator, Decimal, Nullable<Decimal>)
Adds a new data validation rule with a ConstraintType of Decimal to the worksheet in the specified range.
Declaration
public DataValidation AddDecimalRule(string constrainedAddress, ComparisonOperator comparisonOperator, Decimal minValue, Nullable<Decimal> maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | constrainedAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Decimal | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Decimal> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddFormulaListRule(Cell, String)
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddFormulaListRule(Cell constrainedCell, string formula)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell | The cell to which the data validation rule will be applied. |
System.String | formula | The formula of a range of cells whose values will be used to populate the drop-down list. Can also be a name of the Named table on this same sheet. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddFormulaListRule(Range, String)
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddFormulaListRule(Range constrainedRange, string formula)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange | The range to which the data validation rule will be applied. |
System.String | formula | The formula of a range of cells whose values will be used to populate the drop-down list. Can also be a name of the Named table on this same sheet. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddFormulaListRule(RangeAddress, String)
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddFormulaListRule(RangeAddress constrainedRangeAddress, string formula)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | constrainedRangeAddress | The range address to which the data validation rule will be applied. |
System.String | formula | The formula of a range of cells whose values will be used to populate the drop-down list. Can also be a name of the Named table on this same sheet. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | |
System.InvalidOperationException | |
System.ArgumentException |
AddFormulaListRule(String, String)
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddFormulaListRule(string constrainedAddress, string formula)
Parameters
Type | Name | Description |
---|---|---|
System.String | constrainedAddress | The range address to which the data validation rule will be applied. |
System.String | formula | The formula of a range of cells whose values will be used to populate the drop-down list. Can also be a name of the Named table on this same sheet. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddIntegerRule(Cell, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of WholeNumber to the worksheet in the specified range.
Declaration
public DataValidation AddIntegerRule(Cell constrainedCell, ComparisonOperator comparisonOperator, int minValue, Nullable<int> maxValue)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell | The cell to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Int32> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddIntegerRule(Range, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of WholeNumber to the worksheet in the specified range.
Declaration
public DataValidation AddIntegerRule(Range constrainedRange, ComparisonOperator comparisonOperator, int minValue, Nullable<int> maxValue)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Int32> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddIntegerRule(RangeAddress, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of WholeNumber to the worksheet in the specified range.
Declaration
public DataValidation AddIntegerRule(RangeAddress constrainedRangeAddress, ComparisonOperator comparisonOperator, int minValue, Nullable<int> maxValue)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | constrainedRangeAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Int32> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddIntegerRule(String, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of WholeNumber to the worksheet in the specified range.
Declaration
public DataValidation AddIntegerRule(string constrainedAddress, ComparisonOperator comparisonOperator, int minValue, Nullable<int> maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | constrainedAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minValue | The minimum value for the data validation rule. |
System.Nullable<System.Int32> | maxValue | The maximum value for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddStringListRule(Cell, String[])
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddStringListRule(Cell constrainedCell, string[] values)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell | The cell to which the data validation rule will be applied. |
System.String[] | values | The values to populate the drop-down list with. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddStringListRule(Range, String[])
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddStringListRule(Range constrainedRange, string[] values)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange | The range to which the data validation rule will be applied. |
System.String[] | values | The values to populate the drop-down list with. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddStringListRule(RangeAddress, String[])
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddStringListRule(RangeAddress constrainedRangeAddress, string[] values)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | constrainedRangeAddress | The range address to which the data validation rule will be applied. |
System.String[] | values | The values to populate the drop-down list with. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddStringListRule(String, String[])
Adds a new data validation rule with a ConstraintType of List to the worksheet in the specified range.
Declaration
public DataValidation AddStringListRule(string constrainedAddress, string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | constrainedAddress | The range address to which the data validation rule will be applied. |
System.String[] | values | The values to populate the drop-down list with. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddTextLengthRule(Cell, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddTextLengthRule(Cell constrainedCell, ComparisonOperator comparisonOperator, int minLength, Nullable<int> maxLength)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell | The cell to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minLength | The minimum string length for the data validation rule. |
System.Nullable<System.Int32> | maxLength | The maximum string length for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddTextLengthRule(Range, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddTextLengthRule(Range constrainedRange, ComparisonOperator comparisonOperator, int minLength, Nullable<int> maxLength)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange | The range to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minLength | The minimum string length for the data validation rule. |
System.Nullable<System.Int32> | maxLength | The maximum string length for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddTextLengthRule(RangeAddress, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddTextLengthRule(RangeAddress constrainedRangeAddress, ComparisonOperator comparisonOperator, int minLength, Nullable<int> maxLength)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | constrainedRangeAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minLength | The minimum string length for the data validation rule. |
System.Nullable<System.Int32> | maxLength | The maximum string length for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
AddTextLengthRule(String, ComparisonOperator, Int32, Nullable<Int32>)
Adds a new data validation rule with a ConstraintType of Date to the worksheet in the specified range.
Declaration
public DataValidation AddTextLengthRule(string constrainedAddress, ComparisonOperator comparisonOperator, int minLength, Nullable<int> maxLength)
Parameters
Type | Name | Description |
---|---|---|
System.String | constrainedAddress | The range address to which the data validation rule will be applied. |
ComparisonOperator | comparisonOperator | The comparison operator to use when validating data. |
System.Int32 | minLength | The minimum string length for the data validation rule. |
System.Nullable<System.Int32> | maxLength | The maximum string length for the data validation rule. |
Returns
Type | Description |
---|---|
DataValidation | The created DataValidation object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | |
System.ArgumentNullException | |
System.InvalidOperationException |
GetEnumerator()
Gets the enumerator.
Declaration
public IEnumerator<DataValidation> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<DataValidation> |
GetRuleForCell(Cell)
Gets the data validation rule that applies to the specified cell.
Declaration
public DataValidation GetRuleForCell(Cell constrainedCell)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell | The cell to check. |
Returns
Type | Description |
---|---|
DataValidation |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
GetRulesForRange(Range)
Gets the data validation rules that applies to the specified range.
Declaration
public DataValidationsCollection GetRulesForRange(Range constrainedRange)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange | The range to check. |
Returns
Type | Description |
---|---|
DataValidationsCollection |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
GetRulesForRange(RangeAddress)
Gets the data validation rules that applies to the specified range.
Declaration
public DataValidationsCollection GetRulesForRange(RangeAddress rangeAddress)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | rangeAddress | The range to check. |
Returns
Type | Description |
---|---|
DataValidationsCollection |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
GetRulesForRange(String)
Gets the data validation rules that applies to the specified range.
Declaration
public DataValidationsCollection GetRulesForRange(string constrainedAddress)
Parameters
Type | Name | Description |
---|---|---|
System.String | constrainedAddress | The address of the range in A1 notation. |
Returns
Type | Description |
---|---|
DataValidationsCollection |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
RangeAlreadyHasDataValidation(RangeAddress)
Checks if the specified range already has a data validation rule.
Declaration
public bool RangeAlreadyHasDataValidation(RangeAddress rangeAddress)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | rangeAddress |
Returns
Type | Description |
---|---|
System.Boolean |
Remove(DataValidation)
Remove a specified data validation rule from the worksheet.
Declaration
public void Remove(DataValidation dataValidation)
Parameters
Type | Name | Description |
---|---|---|
DataValidation | dataValidation | The data validation rule to remove. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
RemoveAllRulesFromRange(Range)
Remove all data validation rules from the range on this worksheet.
Declaration
public void RemoveAllRulesFromRange(Range constrainedRange)
Parameters
Type | Name | Description |
---|---|---|
Range | constrainedRange |
RemoveAllRulesFromRange(RangeAddress)
Remove all data validation rules from the range on this worksheet.
Declaration
public void RemoveAllRulesFromRange(RangeAddress rangeAddress)
Parameters
Type | Name | Description |
---|---|---|
RangeAddress | rangeAddress |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
RemoveAllRulesFromRange(String)
Remove all data validation rules from the range on this worksheet.
Declaration
public void RemoveAllRulesFromRange(string address)
Parameters
Type | Name | Description |
---|---|---|
System.String | address |
RemoveAt(Int32)
Remove a data validation rule at the specified index from the worksheet.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the data validation rule to remove. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
RemoveRuleFromCell(Cell)
Remove all data validation rules from the cell on this worksheet.
Declaration
public void RemoveRuleFromCell(Cell constrainedCell)
Parameters
Type | Name | Description |
---|---|---|
Cell | constrainedCell |