PivotGridGroupCollection Class
Represents a collection of field groups.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v19.1.dll
Declaration
public class PivotGridGroupCollection :
PivotChildCollection<PivotGridGroup>,
ILockable
Public Class PivotGridGroupCollection
Inherits PivotChildCollection(Of PivotGridGroup)
Implements ILockable
The following members return PivotGridGroupCollection objects:
The DXPivotGrid provides the capability to arrange fields into groups. Fields which are grouped cannot be separated by end-users by dragging one of them to a different area. Field groups are represented by PivotGridGroup objects, and these are stored within the PivotGridControl.Groups collection.
To learn more, see Field Groups.
Example
The following example demonstrates how to combine fields into a group.
In this example, three fields (“Country”, “Region” and “City”) are combined in a new group, in this order. This ensures that the “Country” field is followed by “Region”, which is in turn followed by “City”. If the “Region” field is dragged to another area, the other fields accompany it.
using System.Windows;
using DevExpress.Xpf.PivotGrid;
using HowToBindToMDB.NwindDataSetTableAdapters;
namespace HowToBindToMDB {
public partial class MainWindow : Window {
NwindDataSet.SalesPersonDataTable salesPersonDataTable =
new NwindDataSet.SalesPersonDataTable();
SalesPersonTableAdapter salesPersonDataAdapter = new SalesPersonTableAdapter();
public MainWindow() {
InitializeComponent();
pivotGridControl1.DataSource = salesPersonDataTable;
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
salesPersonDataAdapter.Fill(salesPersonDataTable);
// Create a group at run-time
PivotGridGroup group = pivotGridControl1.Groups.Add(fieldCategoryName, fieldProductName);
}
}
}
<Window x:Class="HowToBindToMDB.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<dxpg:PivotGridControl HorizontalAlignment="Left" Name="pivotGridControl1"
VerticalAlignment="Top">
<dxpg:PivotGridControl.Fields>
<dxpg:PivotGridField Name="fieldCountry" FieldName="Country" Area="RowArea"
Group="{Binding ElementName=groupCountryCustomer}" />
<dxpg:PivotGridField Name="fieldCustomer" FieldName="Sales Person" Area="RowArea"
Group="{Binding ElementName=groupCountryCustomer}"
Caption="Customer"/>
<dxpg:PivotGridField Name="fieldYear" FieldName="OrderDate" Area="FilterArea"
Caption="Year" GroupInterval="DateYear" />
<dxpg:PivotGridField Name="fieldCategoryName" FieldName="CategoryName"
Area="ColumnArea" Caption="Product Category" />
<dxpg:PivotGridField Name="fieldProductName" FieldName="ProductName"
Area="ColumnArea" Caption="Product Name" />
<dxpg:PivotGridField Name="fieldExtendedPrice" FieldName="Extended Price"
Area="DataArea" CellFormat="c0" />
</dxpg:PivotGridControl.Fields>
<dxpg:PivotGridControl.Groups>
<dxpg:PivotGridGroup Name="groupCountryCustomer" />
</dxpg:PivotGridControl.Groups>
</dxpg:PivotGridControl>
</Grid>
</Window>
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid
Imports HowToBindToMDB.NwindDataSetTableAdapters
Namespace HowToBindToMDB
Partial Public Class MainWindow
Inherits Window
Private salesPersonDataTable As New NwindDataSet.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)
' Create a group at run-time
Dim group As PivotGridGroup = _
pivotGridControl1.Groups.Add(fieldCategoryName, fieldProductName)
End Sub
End Class
End Namespace
See Also