Skip to main content

PivotGridControl.Selection Property

Gets or sets the coordinates of the selected cells.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v23.2.dll

NuGet Package: DevExpress.Wpf.PivotGrid


public Rectangle Selection { get; set; }

Property Value

Type Description

A Rectangle object which contains the coordinates of the selected cells.


If the PivotGridControl.SelectMode property is set to ‘SolidSelection’, an end-user can select a continuous block of cells. The Left and Top members of the Selection property identify the column index and row index of the left-topmost selected cell. The Width and Height members specify the number of selected columns and rows, respectively.


If the PivotGridControl.SelectMode property is set to ‘MultiSelection’, a user can select several blocks of cells via the mouse with the Ctrl key pressed down. In this instance, to obtain selected cells, use the PivotGridControl.MultiSelection property.


The following example demonstrates how to copy data from the PivotGridControl into the system clipboard.

First, it is necessary to add the ContextMenu with a single “Copy to Clipboard” menu item to a PivotGridControl‘s ContextMenu property. This context menu is invoked when an end-user right-clicks within the Data Area. Then this menu’s Click event can be handled to copy data to the clipboard. To copy the selected cells to the clipboard, the PivotGridControl.CopySelectionToClipboard method is used.

To determine whether the selection is not empty, and so whether it is necessary to invoke the context menu, the PivotGridControl.ContextMenuOpening event should be handled.

<Window x:Class="HowToBindToMDB.MainWindow"
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
        <dxpg:PivotGridControl ContextMenuOpening="pivotGridControl1_ContextMenuOpening"
                               HorizontalAlignment="Left" Name="pivotGridControl1" 
                    <MenuItem Header="Copy Selection to Clipboard" 
                <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" />
See Also