Skip to main content

How to: Remove Items from the Context Menu

  • 2 minutes to read

This example shows how to remove items from the PivoGridControl context menu.In this sample, the 'Show Prefilter', 'Show Field List' and 'Refresh Data' items are removed from the field headers' context menu. For this purpose, three RemoveBarItemAndLinkAction objects are added to the control's HeaderMenuCustomizations collection. Their ItemName properties are set to DefaultMenuItemNames.ShowPrefilter, DefaultMenuItemNames.ShowFieldList and DefaultMenuItemNames.RefreshData, respectively.

Imports Microsoft.VisualBasic
Imports System.Windows
Imports DXPivotGrid_HidingContextMenuItems.DataSet1TableAdapters

Namespace DXPivotGrid_HidingContextMenuItems
    Partial Public Class MainWindow
        Inherits Window
        Private salesPersonDataTable As New DataSet1.SalesPersonDataTable()
        Private salesPersonDataAdapter As New SalesPersonTableAdapter()
        Public Sub New()
            InitializeComponent()
            pivotGridControl1.DataSource = salesPersonDataTable
        End Sub
        Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            salesPersonDataAdapter.Fill(salesPersonDataTable)
            pivotGridControl1.CollapseAllColumns()
        End Sub
    End Class
End Namespace