DevExpress v24.2 Update — Your Feedback Matters
Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.
Take the survey
Not interested
The following example shows how to localize a PivotGridControl via the PivotGridLocalizer class.
In this example, grand total headers (‘Grand Total’ by default) are replaced with ‘Aggregate Total’, automatic total header patterns (‘{0} Total’ by default) are replaced with ‘Total for {0}’, and the text displayed within the Filter Header Area (‘Drop Filter Fields Here’ by default) is replaced with ‘Filter Header Area is currently empty’. To do this, a PivotGridLocalizer class descendant (CustomDXPivotGridLocalizer) has been created, and its GetLocalizedString method is overridden to replace the default strings.
For other localization approaches, refer to Localization .
Imports Microsoft.VisualBasic
Imports System.Windows
Imports System.Windows.Data
Imports DevExpress.XtraPivotGrid.Localization
Imports DXPivotGrid_Localization.DataSet1TableAdapters
Namespace DXPivotGrid_Localization
Partial Public Class MainWindow
Inherits Window
Private salesPersonDataTable As New DataSet1.SalesPersonDataTable()
Private salesPersonDataAdapter As New SalesPersonTableAdapter()
Public Sub New ()
PivotGridLocalizer.Active = New CustomDXPivotGridLocalizer()
InitializeComponent()
pivotGridControl1.DataSource = salesPersonDataTable
End Sub
Private Sub Window_Loaded(ByVal sender As Object , ByVal e As RoutedEventArgs)
salesPersonDataAdapter.Fill(salesPersonDataTable)
Dim nwindDataSet As DataSet1 = (CType (Me .FindResource("nwindDataSet" ), DataSet1))
Dim nwindDataSetCategoryProductsTableAdapter As New CategoryProductsTableAdapter()
nwindDataSetCategoryProductsTableAdapter.Fill(nwindDataSet.CategoryProducts)
Dim categoryProductsViewSource As CollectionViewSource = _
(CType (Me .FindResource("categoryProductsViewSource" ), CollectionViewSource))
categoryProductsViewSource.View.MoveCurrentToFirst()
End Sub
End Class
Public Class CustomDXPivotGridLocalizer
Inherits PivotGridLocalizer
Public Overrides Function GetLocalizedString(ByVal id As PivotGridStringId) As String
Select Case id
Case PivotGridStringId.GrandTotal
Return "Aggregate Total"
Case PivotGridStringId.TotalFormat
Return "Total for {0}"
Case PivotGridStringId.FilterHeadersCustomization
Return "Filter Header Area is currently empty"
Case Else
Return MyBase .GetLocalizedString(id)
End Select
End Function
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" xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my ="clr-namespace:DXPivotGrid_Localization" x:Class ="DXPivotGrid_Localization.MainWindow" Title ="MainWindow" Height ="350" Width ="487" Loaded ="Window_Loaded" >
<Window.Resources >
<my:DataSet1 x:Key ="nwindDataSet" />
<CollectionViewSource x:Key ="categoryProductsViewSource" Source ="{Binding Path=CategoryProducts, Source={StaticResource nwindDataSet}}" />
</Window.Resources >
<Grid DataContext ="{StaticResource categoryProductsViewSource}" >
<dxpg:PivotGridControl HorizontalAlignment ="Left" Name ="pivotGridControl1" VerticalAlignment ="Top" FieldListStyle ="Excel2007" >
<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 ="fieldExtendedPrice" FieldName ="Extended Price" Area ="DataArea" CellFormat ="c0" />
</dxpg:PivotGridControl.Fields >
</dxpg:PivotGridControl >
</Grid >
</Window >
using System.Windows ;
using System.Windows.Data ;
using DevExpress.XtraPivotGrid.Localization ;
using DXPivotGrid_Localization.DataSet1TableAdapters;
namespace DXPivotGrid_Localization {
public partial class MainWindow : Window {
DataSet1.SalesPersonDataTable salesPersonDataTable = new DataSet1.SalesPersonDataTable();
SalesPersonTableAdapter salesPersonDataAdapter = new SalesPersonTableAdapter();
public MainWindow ( ) {
PivotGridLocalizer.Active = new CustomDXPivotGridLocalizer();
InitializeComponent();
pivotGridControl1.DataSource = salesPersonDataTable;
}
private void Window_Loaded (object sender, RoutedEventArgs e ) {
salesPersonDataAdapter.Fill(salesPersonDataTable);
DataSet1 nwindDataSet = ((DataSet1)(this .FindResource("nwindDataSet" )));
CategoryProductsTableAdapter nwindDataSetCategoryProductsTableAdapter =
new CategoryProductsTableAdapter();
nwindDataSetCategoryProductsTableAdapter.Fill(nwindDataSet.CategoryProducts);
CollectionViewSource categoryProductsViewSource =
((CollectionViewSource)(this .FindResource("categoryProductsViewSource" )));
categoryProductsViewSource.View.MoveCurrentToFirst();
}
}
public class CustomDXPivotGridLocalizer : PivotGridLocalizer {
public override string GetLocalizedString (PivotGridStringId id ) {
switch (id) {
case PivotGridStringId.GrandTotal:
return "Aggregate Total" ;
case PivotGridStringId.TotalFormat:
return "Total for {0}" ;
case PivotGridStringId.FilterHeadersCustomization:
return "Filter Header Area is currently empty" ;
default :
return base .GetLocalizedString(id);
}
}
}
}