officefileapi-devexpress-dot-spreadsheet-dot-datavalidationcollection-dot-removeat-x28-system-dot-int32-x29.md
Removes the data validation item at the specified index from the collection.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
void RemoveAt(
int index
)
Sub RemoveAt(
index As Integer
)
| Name | Type | Description |
|---|---|---|
| index | Int32 |
A zero-based integer specifying the index of the item to be removed. It should be non-negative and less than the number of elements in the collection.
|
To remove the specified DataValidation object, use the DataValidationCollection.Remove method. To remove all data validations from the worksheet, use the DataValidationCollection.Clear method.
workbook.LoadDocument("Documents\\DataValidation.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
// Add data validations.
worksheet.DataValidations.Add(worksheet["D4:D11"], DataValidationType.TextLength, DataValidationOperator.Equal, 3);
worksheet.DataValidations.Add(worksheet["E4:E11"], DataValidationType.List, ValueObject.FromRange(worksheet["H4:H9"].GetRangeWithAbsoluteReference()));
// Remove data validation by index.
worksheet.DataValidations.RemoveAt(1);
// 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]);
}
workbook.LoadDocument("Documents\DataValidation.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Add data validations.
worksheet.DataValidations.Add(worksheet("D4:D11"), DataValidationType.TextLength, DataValidationOperator.Equal, 3)
worksheet.DataValidations.Add(worksheet("E4:E11"), DataValidationType.List, ValueObject.FromRange(worksheet("H4:H9").GetRangeWithAbsoluteReference()))
' Remove data validation by index.
worksheet.DataValidations.RemoveAt(1)
' 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 RemoveAt(Int32) method.
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.
// Remove data validation by index.
worksheet.DataValidations.RemoveAt(1);
// Remove data validation by index.
worksheet.DataValidations.RemoveAt(1);
// Remove a data validation by its index.
worksheet.DataValidations.RemoveAt(1);
' Remove data validation by index.
worksheet.DataValidations.RemoveAt(1)
' Highlight data validation ranges.
' Remove a data validation by its index.
worksheet.DataValidations.RemoveAt(1)
See Also
DataValidationCollection Interface