The following example shows how to display the records from the control's underlying data source which correspond to a particular cell. A new form that displays these records is opened when a particular cell in the PivotGrid control is double-clicked.
In the example the DevExpress.XtraPivotGrid.PivotGridControl.CellDoubleClick event is handled. The PivotCellEventArgsBase<TField, TData, TCustomTotal>.CreateDrillDownDataSource (see PivotCellEventArgsBase<TField, TData, TCustomTotal>.CreateDrillDownDataSource) method is called to obtain the list of records associated with the clicked cell.
The following image shows a sample PivotGrid control which is bound to the Invoices table in the nwind.mdb database:

Clicking the third cell in the 1994 column will invoke the following form:

It lists all the orders made in 1994 by Belgian customers.
C# |
using DevExpress.XtraPivotGrid;
private void pivotGridControl1_CellDoubleClick(object sender, PivotCellEventArgs e) {
Form form = new Form();
form.Text = "Records";
DataGrid grid = new DataGrid();
grid.Parent = form;
grid.Dock = DockStyle.Fill;
grid.DataSource = e.CreateDrillDownDataSource();
form.Bounds = new Rectangle(100, 100, 500, 400);
form.ShowDialog();
form.Dispose();
}
|
VB |
Imports DevExpress.XtraPivotGrid
Private Sub pivotGridControl1_CellDoubleClick(ByVal sender As Object, _
ByVal e As PivotCellEventArgs) Handles pivotGridControl1.CellDoubleClick
Dim form As Form = New Form
form.Text = "Records"
Dim grid As DataGrid = New DataGrid
grid.Parent = form
grid.Dock = DockStyle.Fill
grid.DataSource = e.CreateDrillDownDataSource()
form.Bounds = New Rectangle(100, 100, 500, 400)
form.ShowDialog()
form.Dispose()
End Sub
|