Back to Devexpress

PivotFieldReferenceCollection.Remove(PivotFieldReference) Method

officefileapi-devexpress-dot-spreadsheet-dot-pivotfieldreferencecollection-dot-remove-x28-devexpress-dot-spreadsheet-dot-pivotfieldreference-x29.md

latest6.9 KB
Original Source

PivotFieldReferenceCollection.Remove(PivotFieldReference) Method

Removes the specified row or column field from the collection.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void Remove(
    PivotFieldReference fieldReference
)
vb
Sub Remove(
    fieldReference As PivotFieldReference
)

Parameters

NameTypeDescription
fieldReferencePivotFieldReference

A PivotFieldReference object that specifies the row or column field to be removed from the collection.

|

Remarks

Use the Remove method to remove the specified row field from the PivotTable.RowFields collection (as shown in the example below), or the specified column field from the PivotTable.ColumnFields collection.

View Example

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")

' Remove the "Product" field from the row axis area.
pivotTable.RowFields.Remove(pivotTable.RowFields("Product"))
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"];

// Remove the "Product" field from the row axis area.
pivotTable.RowFields.Remove(pivotTable.RowFields["Product"]);

To remove a row (or column) field from the PivotTable.RowFields (or PivotTable.ColumnFields) collection by its index, use the PivotFieldReferenceCollection.RemoveAt method. To remove all fields from the collection of row or column fields, use the PivotFieldReferenceCollection.Clear method.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Remove(PivotFieldReference) 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/PivotFieldActions.cs#L97

csharp
// Remove the "Product" field from the row axis area.
pivotTable.RowFields.Remove(pivotTable.RowFields["Product"]);
#endregion #RemoveFromAxis

winforms-spreadsheet-pivot-table-api/CS/SpreadsheetPivotTableExamples/CodeExamples/PivotFieldActions.cs#L96

csharp
// Remove the "Product" field from the row axis area.
pivotTable.RowFields.Remove(pivotTable.RowFields["Product"]);
#endregion #RemoveFromAxis

spreadsheet-document-api-pivot-table-examples/CS/SpreadsheetDocServerPivotAPI/CodeExamples/PivotFieldActions.cs#L108

csharp
// Remove the "Product" field from the row axis area.
pivotTable.RowFields.Remove(pivotTable.RowFields["Product"]);
#endregion #RemoveFromAxis

wpf-spreadsheet-pivot-table-api-examples/VB/SpreadsheetWPFPivotTableExamples/CodeExamples/PivotFieldActions.vb#L93

vb
' Remove the "Product" field from the row axis area.
            pivotTable.RowFields.Remove(pivotTable.RowFields("Product"))
' #End Region ' #RemoveFromAxis

winforms-spreadsheet-pivot-table-api/VB/SpreadsheetPivotTableExamples/CodeExamples/PivotFieldActions.vb#L92

vb
' Remove the "Product" field from the row axis area.
            pivotTable.RowFields.Remove(pivotTable.RowFields("Product"))
' #End Region ' #RemoveFromAxis

spreadsheet-document-api-pivot-table-examples/VB/SpreadsheetDocServerPivotAPI/CodeExamples/PivotFieldActions.vb#L100

vb
' Remove the "Product" field from the row axis area.
            pivotTable.RowFields.Remove(pivotTable.RowFields("Product"))
#End Region ' #RemoveFromAxis

See Also

RemoveAt(Int32)

Clear()

PivotFieldReferenceCollection Interface

PivotFieldReferenceCollection Members

DevExpress.Spreadsheet Namespace