Back to Devexpress

PivotCalculatedItemCollection.RemoveAt(Int32) Method

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

latest6.8 KB
Original Source

PivotCalculatedItemCollection.RemoveAt(Int32) Method

Removes the calculated 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 calculated item to be removed. It should be non-negative and less than the number of elements in the collection.

|

Remarks

To remove the specified calculated item from the collection, use the PivotCalculatedItemCollection.Remove method. To remove all calculated items from the collection at once, use the PivotCalculatedItemCollection.Clear method.

Example

View Example

csharp
Worksheet worksheet = workbook.Worksheets["Report7"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];

// Access the pivot field by its name in the collection.
PivotField field = pivotTable.Fields["Customer"];

// Add a calculated item to the "Customer" field.
field.CalculatedItems.Add("='Big Foods'*110%", "Big Foods Sales Plan");

//Remove the calculated item by its index from the collection.
field.CalculatedItems.RemoveAt(0);
vb
Dim worksheet As Worksheet = workbook.Worksheets("Report7")
workbook.Worksheets.ActiveWorksheet = worksheet

' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")

' Access the pivot field by its name in the collection.
Dim field As PivotField = pivotTable.Fields("Customer")

' Add a calculated item to the "Customer" field.
field.CalculatedItems.Add("='Big Foods'*110%", "Big Foods Sales Plan")

'Remove the calculated item by its index from the collection.
field.CalculatedItems.RemoveAt(0)

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.

wpf-spreadsheet-pivot-table-api-examples/CS/SpreadsheetWPFPivotTableExamples/CodeExamples/PivotCalculatedItemActions.cs#L41

csharp
//Remove the calculated item by its index from the collection.
field.CalculatedItems.RemoveAt(0);
#endregion #RemoveCalculatedItem

winforms-spreadsheet-pivot-table-api/CS/SpreadsheetPivotTableExamples/CodeExamples/PivotCalculatedItemActions.cs#L41

csharp
//Remove the calculated item by its index from the collection.
field.CalculatedItems.RemoveAt(0);
#endregion #RemoveCalculatedItem

spreadsheet-document-api-pivot-table-examples/CS/SpreadsheetDocServerPivotAPI/CodeExamples/PivotCalculatedItemActions.cs#L47

csharp
//Remove the calculated item by its index from the collection.
field.CalculatedItems.RemoveAt(0);
#endregion #RemoveCalculatedItem

wpf-spreadsheet-pivot-table-api-examples/VB/SpreadsheetWPFPivotTableExamples/CodeExamples/PivotCalculatedItemActions.vb#L37

vb
'Remove the calculated item by its index from the collection.
            field.CalculatedItems.RemoveAt(0)
' #End Region ' #RemoveCalculatedItem

winforms-spreadsheet-pivot-table-api/VB/SpreadsheetPivotTableExamples/CodeExamples/PivotCalculatedItemActions.vb#L37

vb
'Remove the calculated item by its index from the collection.
            field.CalculatedItems.RemoveAt(0)
' #End Region ' #RemoveCalculatedItem

spreadsheet-document-api-pivot-table-examples/VB/SpreadsheetDocServerPivotAPI/CodeExamples/PivotCalculatedItemActions.vb#L43

vb
'Remove the calculated item by its index from the collection.
            field.CalculatedItems.RemoveAt(0)
#End Region ' #RemoveCalculatedItem

See Also

Remove(PivotItem)

Clear()

PivotCalculatedItemCollection Interface

PivotCalculatedItemCollection Members

DevExpress.Spreadsheet Namespace