$npx -y skills add DevExpress/agent-skills --skill devexpress-winforms-pivot-gridAI agent skill for the DevExpress WinForms PivotGridControl. Covers NuGet setup, data binding (DataSourceColumnBinding, ExpressionDataBinding, OLAP), field areas and layout, summaries, grouping, sorting, filtering, conditional formatting (FormatRules), and appearance customizatio
| 1 | # DevExpress WinForms Pivot Grid (PivotGridControl) |
| 2 | |
| 3 | `PivotGridControl` (namespace `DevExpress.XtraPivotGrid`) is a cross-tabulation control that summarizes bound data across row and column dimensions — like an Excel PivotTable. Fields are assigned to four areas (Row, Column, Data, Filter); the control computes summaries at every intersection. |
| 4 | |
| 5 | ## Before You Start — Ask the Developer |
| 6 | |
| 7 | If the host agent has a structured question-asking tool available, use it to ask these questions one at a time with clear options — for example, Claude Code's `AskUserQuestion` tool or GitHub Copilot's `askQuestions` tool. If no such tool is available, ask the questions directly in the chat response before generating code. |
| 8 | |
| 9 | 1. **Data source?** In-memory `List<T>`/`DataTable`, EF/EF Core, an OLAP cube (SSAS), or an Excel file? This decides the binding approach (see the Decision Guide). |
| 10 | 2. **Which fields go where?** Which columns become Row / Column / Data / Filter fields, and which need calculated or grouped bindings (`ExpressionDataBinding`, `GroupInterval`)? |
| 11 | 3. **Summaries?** Default `Sum`, or other `SummaryType` / custom summaries? Any % of total / running totals? |
| 12 | 4. **Layout & interactivity?** Should end users rearrange fields (Customization Form), or is the layout fixed in code? |
| 13 | 5. **Formatting?** Cell number formats, conditional formatting (`FormatRules`: bars/scales/icons), and appearance/skin requirements? |
| 14 | 6. **Scale & responsiveness?** Large in-memory data → `Optimized` engine + `UseAsyncMode`. Large *database* table → server mode (`EntityServerModeSource`) so aggregation runs in SQL. |
| 15 | 7. **Persistence?** Save/restore the layout (`SaveLayoutToXml` / `RestoreLayoutFromXml`)? |
| 16 | |
| 17 | ## Reference Files |
| 18 | |
| 19 | | Topic | File | |
| 20 | |---|---| |
| 21 | | NuGet setup, first binding, async mode | [references/getting-started.md](references/getting-started.md) | |
| 22 | | DataSource types, DataSourceColumnBinding, OLAP, server mode (large data), calculated bindings | [references/data-binding.md](references/data-binding.md) | |
| 23 | | Field areas, totals, groups, BestFit, Customization Form | [references/view-layout.md](references/view-layout.md) | |
| 24 | | SummaryType, custom summaries, GroupInterval, sorting, TopN, FilterValues | [references/summaries-grouping-sorting-filtering.md](references/summaries-grouping-sorting-filtering.md) | |
| 25 | | FormatRules, PivotGridFormatRule, rule types | [references/conditional-formatting.md](references/conditional-formatting.md) | |
| 26 | | PivotGridAppearances, per-field style, CustomDrawCell, skins | [references/appearance.md](references/appearance.md) | |
| 27 | |
| 28 | --- |
| 29 | |
| 30 | ## Quick Start (Minimal Working Example) |
| 31 | |
| 32 | ```csharp |
| 33 | // NuGet: DevExpress.Win.PivotGrid |
| 34 | // Assembly: DevExpress.XtraPivotGrid.v26.1.dll |
| 35 | using DevExpress.XtraEditors; |
| 36 | using DevExpress.XtraPivotGrid; |
| 37 | |
| 38 | public partial class Form1 : XtraForm |
| 39 | { |
| 40 | public Form1() |
| 41 | { |
| 42 | InitializeComponent(); |
| 43 | |
| 44 | pivotGridControl1.BeginUpdate(); |
| 45 | try |
| 46 | { |
| 47 | pivotGridControl1.OptionsData.DataProcessingEngine = |
| 48 | PivotDataProcessingEngine.Optimized; |
| 49 | pivotGridControl1.DataSource = GetSalesData(); // IList / DataTable / BindingSource |
| 50 | pivotGridControl1.Fields.AddDataSourceColumn("Country", PivotArea.FilterArea); |
| 51 | pivotGridControl1.Fields.AddDataSourceColumn("Category", PivotArea.RowArea); |
| 52 | pivotGridControl1.Fields.AddDataSourceColumn("Year", PivotArea.ColumnArea); |
| 53 | pivotGridControl1.Fields.AddDataSourceColumn("Sales", PivotArea.DataArea); |
| 54 | } |
| 55 | finally |
| 56 | { |
| 57 | pivotGridControl1.EndUpdate(); // always unlock, even if setup throws |
| 58 | } |
| 59 | pivotGridControl1.BestFit(); |
| 60 | } |
| 61 | } |
| 62 | ``` |
| 63 | |
| 64 | --- |
| 65 | |
| 66 | ## Decision Guide |
| 67 | |
| 68 | ### What data source to use? |
| 69 | |
| 70 | | Scenario | Approach | |
| 71 | |---|---| |
| 72 | | In-memory `List<T>` / `DataTable` | `DataSource = myList` + `Optimized` engine | |
| 73 | | Entity Framework / EF Core (small/medium) | `DataSource = dbContext.Orders.ToList()` | |
| 74 | | Large database table (EF Core / LINQ) | **Server mode** — `DataSource = new EntityServerModeSource { ElementType=…, QueryableSource=…, KeyExpression=… }` (aggregates in SQL) | |
| 75 | | OLAP cube (SSAS) | Set `OLAPCon |