Back to Devexpress

PivotCalculatedFieldCollection.RemoveAt(Int32) Method

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

latest6.8 KB
Original Source

PivotCalculatedFieldCollection.RemoveAt(Int32) Method

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

|

Remarks

To remove the specified calculated field from the collection, use the PivotCalculatedFieldCollection.Remove method. To remove all calculated fields from the collection at once, use the PivotCalculatedFieldCollection.Clear method.

Example

View Example

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

// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];
// Create a calculated field based on data in the "Sales" field.
pivotTable.CalculatedFields.Add("=Sales*10%", "Sales Tax");
// Access the calculated field by its name in the collection.
PivotField field = pivotTable.CalculatedFields["Sales Tax"];
// Add the calculated field to the data area. 
PivotDataField dataField = pivotTable.DataFields.Add(field);
//Remove the calculated field.
pivotTable.CalculatedFields.RemoveAt(0);
vb
Dim worksheet As Worksheet = workbook.Worksheets("Report1")
workbook.Worksheets.ActiveWorksheet = worksheet

' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")
' Create a calculated field based on data in the "Sales" field.
pivotTable.CalculatedFields.Add("=Sales*10%", "Sales Tax")
' Access the calculated field by its name in the collection.
Dim field As PivotField = pivotTable.CalculatedFields("Sales Tax")
' Add the calculated field to the data area. 
Dim dataField As PivotDataField = pivotTable.DataFields.Add(field)
'Remove the calculated field.
pivotTable.CalculatedFields.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/PivotCalculatedFieldActions.cs#L39

csharp
//Remove the calculated field.
pivotTable.CalculatedFields.RemoveAt(0);
#endregion #RemoveCalculatedField

winforms-spreadsheet-pivot-table-api/CS/SpreadsheetPivotTableExamples/CodeExamples/PivotCalculatedFieldActions.cs#L39

csharp
//Remove the calculated field.
pivotTable.CalculatedFields.RemoveAt(0);
#endregion #RemoveCalculatedField

spreadsheet-document-api-pivot-table-examples/CS/SpreadsheetDocServerPivotAPI/CodeExamples/PivotCalculatedFieldActions.cs#L45

csharp
//Remove the calculated field.
pivotTable.CalculatedFields.RemoveAt(0);
#endregion #RemoveCalculatedField

wpf-spreadsheet-pivot-table-api-examples/VB/SpreadsheetWPFPivotTableExamples/CodeExamples/PivotCalculatedFieldActions.vb#L35

vb
'Remove the calculated field.
            pivotTable.CalculatedFields.RemoveAt(0)
' #End Region ' #RemoveCalculatedField

winforms-spreadsheet-pivot-table-api/VB/SpreadsheetPivotTableExamples/CodeExamples/PivotCalculatedFieldActions.vb#L35

vb
'Remove the calculated field.
            pivotTable.CalculatedFields.RemoveAt(0)
' #End Region ' #RemoveCalculatedField

spreadsheet-document-api-pivot-table-examples/VB/SpreadsheetDocServerPivotAPI/CodeExamples/PivotCalculatedFieldActions.vb#L41

vb
'Remove the calculated field.
            pivotTable.CalculatedFields.RemoveAt(0)
#End Region ' #RemoveCalculatedField

See Also

Remove(PivotField)

Clear()

PivotCalculatedFieldCollection Interface

PivotCalculatedFieldCollection Members

DevExpress.Spreadsheet Namespace