How to: Display Underlying Records
- 2 minutes to read
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 PivotGridControl.CellDoubleClick event is handled. The 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.
using DevExpress.XtraPivotGrid;
private void pivotGridControl1_CellDoubleClick(object sender, PivotCellEventArgs e) {
// Create a new form.
Form form = new Form();
form.Text = "Records";
// Place a DataGrid control on the form.
DataGrid grid = new DataGrid();
grid.Parent = form;
grid.Dock = DockStyle.Fill;
// Get the recrd set associated with the current cell and bind it to the grid.
grid.DataSource = e.CreateDrillDownDataSource();
form.Bounds = new Rectangle(100, 100, 500, 400);
// Display the form.
form.ShowDialog();
form.Dispose();
}