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
<Window xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
x:Class="DXPivotGrid_HidingContextMenuItems.MainWindow"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hiding Context Menu Items"
Height="412" Width="560"
Loaded="Window_Loaded">
<Grid>
<dxpg:PivotGridControl HorizontalAlignment="Left" Name="pivotGridControl1"
VerticalAlignment="Top" AllowHideFields="Always">
<dxpg:PivotGridControl.Fields>
<dxpg:PivotGridField Name="fieldCountry" FieldName="Country" Area="RowArea" />
<dxpg:PivotGridField Name="fieldCustomer" FieldName="Sales Person" Area="RowArea"
Caption="Customer" />
<dxpg:PivotGridField Name="fieldYear" FieldName="OrderDate" Area="ColumnArea"
Caption="Year" GroupInterval="DateYear" />
<dxpg:PivotGridField Name="fieldCategoryName" FieldName="CategoryName"
Area="ColumnArea"
Caption="Product Category" />
<dxpg:PivotGridField Name="fieldProductName" FieldName="ProductName"
Area="FilterArea" Caption="Product Name" />
<dxpg:PivotGridField Name="fieldExtendedPrice" FieldName="Extended Price"
Area="DataArea" CellFormat="c0" />
</dxpg:PivotGridControl.Fields>
<dxpg:PivotGridControl.HeaderMenuCustomizations>
<dxb:RemoveBarItemAndLinkAction ItemName="{x:Static dxpg:DefaultMenuItemNames.ShowPrefilter}" />
<dxb:RemoveBarItemAndLinkAction ItemName="{x:Static dxpg:DefaultMenuItemNames.ShowFieldList}" />
<dxb:RemoveBarItemAndLinkAction ItemName="{x:Static dxpg:DefaultMenuItemNames.RefreshData}" />
</dxpg:PivotGridControl.HeaderMenuCustomizations>
</dxpg:PivotGridControl>
</Grid>
</Window>
using System.Windows;
using DXPivotGrid_HidingContextMenuItems.DataSet1TableAdapters;
namespace DXPivotGrid_HidingContextMenuItems {
public partial class MainWindow : Window {
DataSet1.SalesPersonDataTable salesPersonDataTable = new DataSet1.SalesPersonDataTable();
SalesPersonTableAdapter salesPersonDataAdapter = new SalesPersonTableAdapter();
public MainWindow() {
InitializeComponent();
pivotGridControl1.DataSource = salesPersonDataTable;
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
salesPersonDataAdapter.Fill(salesPersonDataTable);
pivotGridControl1.CollapseAllColumns();
}
}
}