Back to Devexpress

DataValidationCollection.RemoveAt(Int32) Method

officefileapi-devexpress-dot-spreadsheet-dot-datavalidationcollection-dot-removeat-x28-system-dot-int32-x29.md

latest6.1 KB
Original Source

DataValidationCollection.RemoveAt(Int32) Method

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

Declaration

csharp
void RemoveAt(
    int index
)
vb
Sub RemoveAt(
    index As Integer
)

Parameters

NameTypeDescription
indexInt32

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.

|

Remarks

To remove the specified DataValidation object, use the DataValidationCollection.Remove method. To remove all data validations from the worksheet, use the DataValidationCollection.Clear method.

Example

View Example

csharp
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]);
}
vb
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.

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

csharp
// Remove data validation by index.
worksheet.DataValidations.RemoveAt(1);

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

csharp
// Remove data validation by index.
worksheet.DataValidations.RemoveAt(1);

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

csharp
// Remove a data validation by its index.
worksheet.DataValidations.RemoveAt(1);

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

vb
' Remove data validation by index.
worksheet.DataValidations.RemoveAt(1)
' Highlight data validation ranges.

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

vb
' Remove a data validation by its index.
worksheet.DataValidations.RemoveAt(1)

See Also

DataValidationCollection Interface

DataValidationCollection Members

DevExpress.Spreadsheet Namespace