windowsforms-401705-controls-and-libraries-pivot-grid-data-shaping-fixed-pinned-columns.md
The Pivot Grid Control allows you to pin columns to the left or rightmost edge. The pinned columns are never scrolled horizontally, so you can use them as a reference point for adjacent cell values.
To pin or unpin a column, right-click the column’s header and select the corresponding command:
Set the PivotGridOptionsMenu.EnablePinColumnMenu property to false to remove the command from the column’s header context menu.
To pin a column, follow the steps below:
The code snippet below illustrates how to pin the fieldQuantity field values that belong to the February 2015 interval.
using DevExpress.XtraPivotGrid;
//...
public Form1() {
var info = new FixedFieldValue(fieldQuantity);
info.Conditions.Add(
new FixedFieldValueCondition(fieldYear, new DateTime(2015, 2, 1)));
pivotGridControl1.FixedColumnFieldValues.Add(info);
}
Imports DevExpress.XtraPivotGrid
'...
Public Sub New()
Dim info = New FixedFieldValue(fieldQuantity)
info.Conditions.Add(New FixedFieldValueCondition(fieldYear, New DateTime(2015, 2, 1)))
pivotGridControl1.FixedColumnFieldValues.Add(info)
End Sub
If you specify no conditions, the “Grand Total” column is pinned.
pivotGridControl1.FixedColumnFieldValues.Add(new FixedFieldValue(fieldQuantity));
pivotGridControl1.FixedColumnFieldValues.Add(New FixedFieldValue(fieldQuantity))
To change the pinned column’s location, use the PivotGridOptionsView.FixedColumnLocation property. The default position is left.
Use the following API members:
| API | description |
|---|---|
| FixedFieldValue | A column field value to be pinned. |
| FixedFieldValueCondition | A condition used to identify the column to pin. |
| FixedFieldValue.Conditions | Specifies field values that should be pinned. |
| FixedFieldValue.DataField | Gets or sets the data field. Displayed cells’ values in the fixed column are calculated against this data field. |
| FixedFieldValueCondition.Field | Gets or sets the field from the column area. Displayed cells’ values in the fixed column are calculated against this field. |
| FixedFieldValueCondition.Value | Gets or sets the value of the field to be pinned. |
| FixedFieldValueConditionCollection.AddRange | Adds conditions that identify the columns to be pinned to the FixedFieldValueCollection |
| PivotGridOptionsMenu.EnablePinColumnMenu | Gets or sets whether users can invoke the column header context menu. |
Tip
Demo : Pinned Columns module in the XtraPivotGrid MainDemo
Requires a WinForms Subscription. Download
Fixed columns have the following limitations: