Back to Devexpress

PivotItem.Visible Property

officefileapi-devexpress-dot-spreadsheet-dot-pivotitem-630ddcf6.md

latest6.1 KB
Original Source

PivotItem.Visible Property

Gets or sets a value indicating whether the item should be displayed in the report.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
bool Visible { get; set; }
vb
Property Visible As Boolean

Property Value

TypeDescription
Boolean

true , if the item is visible; otherwise, false.

|

Remarks

Use the Visible property to control the visibility of items in a PivotTable field. The following example demonstrates how to hide the first item in the “Product” row field.

View Example

vb
Dim worksheet As Worksheet = workbook.Worksheets("Report4")
workbook.Worksheets.ActiveWorksheet = worksheet

' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")
' Access items of the "Product" field.
Dim pivotFieldItems As PivotItemCollection = pivotTable.Fields(1).Items

' Hide the first item in the "Product" field.
pivotFieldItems(0).Visible = False
csharp
Worksheet worksheet = workbook.Worksheets["Report4"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];
// Access items of the "Product" field.
PivotItemCollection pivotFieldItems = pivotTable.Fields[1].Items;

// Hide the first item in the "Product" field.
pivotFieldItems[0].Visible = false;

To hide all items in a PivotTable field except one, use the PivotField.ShowSingleItem method.

To restore the display of all hidden items in a pivot field, call the PivotField.ShowAllItems method.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Visible property.

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/PivotTableFilterActions.cs#L36

csharp
// Hide the first item in the "Product" field.
pivotFieldItems[0].Visible = false;
#endregion #ItemVisibility

winforms-spreadsheet-pivot-table-api/CS/SpreadsheetPivotTableExamples/CodeExamples/PivotTableFilterActions.cs#L36

csharp
// Hide the first item in the "Product" field.
pivotFieldItems[0].Visible = false;
#endregion #ItemVisibility

spreadsheet-document-api-pivot-table-examples/CS/SpreadsheetDocServerPivotAPI/CodeExamples/PivotTableFilterActions.cs#L44

csharp
// Hide the first item in the "Product" field.
pivotFieldItems[0].Visible = false;
#endregion #ItemVisibility

wpf-spreadsheet-pivot-table-api-examples/VB/SpreadsheetWPFPivotTableExamples/CodeExamples/PivotTableFilterActions.vb#L36

vb
' Hide the first item in the "Product" field.
            pivotFieldItems(0).Visible = False
' #End Region ' #ItemVisibility

winforms-spreadsheet-pivot-table-api/VB/SpreadsheetPivotTableExamples/CodeExamples/PivotTableFilterActions.vb#L36

vb
' Hide the first item in the "Product" field.
            pivotFieldItems(0).Visible = False
' #End Region ' #ItemVisibility

spreadsheet-document-api-pivot-table-examples/VB/SpreadsheetDocServerPivotAPI/CodeExamples/PivotTableFilterActions.vb#L40

vb
' Hide the first item in the "Product" field.
            pivotFieldItems(0).Visible = False
#End Region ' #ItemVisibility

See Also

ShowSingleItem(Int32)

ShowAllItems()

PivotItem Interface

PivotItem Members

DevExpress.Spreadsheet Namespace