Implementing Syncfusion WPF GridControl
The Syncfusion WPF GridControl is a high-performance, cell-oriented grid that functions as a
flexible tabular display engine. It makes no assumptions about data structure, supports virtual
(on-demand) data loading via QueryCellInfo, and provides Excel-like behaviors including formulas,
import/export, clipboard operations, covered cells, and 20+ built-in cell types.
When to Use This Skill
- Adding a GridControl to a WPF application (XAML or code-behind)
- Populating cells via direct assignment or the virtual
QueryCellInfo event
- Configuring cell types (CheckBox, ComboBox, DateTimeEdit, FormulaCell, etc.)
- Customizing cell appearance (background, font, borders, data formats)
- Managing rows and columns (insert, remove, move, freeze, hide)
- Clipboard, undo/redo, and editing behavior
- Interactive features: drag-drop columns, cell drag-drop, resizing
- Formula cell support and the built-in formula library
- Exporting grid data to Excel; importing Excel workbooks into the grid
- Selection modes, events, and virtual mode patterns
- Performance tuning, virtualization, covered ranges, zooming
- Advanced features: comments, tooltips, printing, serialization, autofit
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Required assembly references
- Adding GridControl via designer or programmatically
- Setting
RowCount and ColumnCount
- Populating data by loop vs.
QueryCellInfo virtual event
- Minimal working example
Cell Types
📄 Read: references/cell-types.md
- 20+ built-in cell types: Header, Static, CheckBox, Button, Image, ComboBox,
DropDownList, DateTimeEdit, IntegerEdit, DoubleEdit, CurrencyEdit, PercentEdit,
MaskEdit, UpDownEdit, RichText, DataBoundTemplate, NestedGrid (ScrollGrid)
- Setting
Style.CellType on individual cells or ranges
- ComboBox with
ChoiceList vs. ItemsSource
- Custom cell types (CellModel + CellRenderer pattern)
Appearance and Styling
📄 Read: references/appearance-and-styling.md
GridStyleInfo class and style inheritance hierarchy
- Volatile vs. render cell styles
- Base styles (
BaseStylesMap), TableStyle, RowStyles, ColumnStyles
- Background (solid/gradient), Foreground, Font, text orientation, borders
- Numeric and DateTime format strings;
FormatProvider interface
Managing Rows and Columns
📄 Read: references/managing-rows-and-columns.md
- Setting row/column counts and default sizes
- Hiding and unhiding rows/columns (
SetHidden)
- Freezing rows/columns; footer and header rows/columns
- Inserting, moving, and removing rows/columns at runtime
- Resize behavior and disabling resize controllers
Editing, Clipboard, and Undo/Redo
📄 Read: references/editing-clipboard-undo.md
CopyPasteOption flags (CopyText, CopyCellData, PasteCell, CutCell, XmlCopyPaste)
TextDataExchange for custom delimiters and buffer-based operations
- Clipboard events and
IGridCopyPaste custom implementation
CommandStack: Undo/Redo, BeginTrans, CommitTrans, Rollback
- Creating derived commands for extended undo/redo
Interactive Features
📄 Read: references/interactive-features.md
- Column drag-drop (
AllowDragColumns)
- Excel-like cell drag-drop (
AllowDragDrop, DataObjectConsumerOptions)
- Runtime row/column resizing and disabling resize controllers
- Hide/unhide rows and columns visually (
HiddenBorderBrush, SetHidden)
Formula Cells
📄 Read: references/formula-cells.md
- Enabling
FormulaCell type for individual cells or the entire grid
- Built-in formula library (150+ functions: Sum, Avg, Sqrt, Pow, Cos, Sin, etc.)
- Arithmetic operators and calculation precedence
- Cross-cell references (A1 notation), named ranges
- Adding custom formula functions to the library
Excel Import and Export
📄 Read: references/excel-import-export.md
- Required assemblies (
Syncfusion.XlsIO, Syncfusion.GridConverter.Wpf)
- Exporting entire or selected grid content to .xls / .xlsx
- Importing Excel workbooks: styles, formulas, conditional formatting, freeze panes,
hyperlinks, comments
- Virtualized import for large workbooks
Selection and Events
📄 Read: references/selection-and-events.md
- Selection modes: cell, row, column (
AllowSelection flags)
QueryCellInfo event pattern for virtual data loading
PrepareRenderCell for view-specific overrides
- Common grid events:
CommitCellInfo, CurrentCellActivated, clipboard events,
RowsInserted, ColumnsMoved, ResizingRows, etc.
- Working with
GridRangeInfo and SelectedRanges
Performance and Virtualization
📄 Read: references/performance-virtualization.md
- Virtual mode fundamentals and
QueryCellInfo best practices
- Covered ranges (
CoveredCells) and floating cells
- Zooming the grid
- High-frequency update patterns
Advanced Features
📄 Read: references/advanced-features.md
- Cell comments, input-message tips, and tooltips
- Cell layout customization (covered cells, merged ranges, autofit)
- Printing grid content
- Serialization: saving and loading grid state
- Autofit rows and columns to content
Quick Start Example
1. Add assemblies:
Syncfusion.Grid.Wpf
Syncfusion.GridCommon.Wpf,
Syncfusion.Linq.Base,
Syncfusion.Shared.Wpf
// 2. XAML — place GridControl inside a ScrollViewer
<ScrollViewer>
<syncfusion:GridControl x:Name="gridControl" />
</ScrollViewer>
// 3. Code-behind: set size and populate
gridControl.Model.RowCount = 100;
gridControl.Model.ColumnCount = 10;
// Option A — direct assignment
for (int i = 0; i < 100; i++)
for (int j = 0; j < 10; j++)
gridControl.Model[i, j].CellValue = $"{i}/{j}";
// Option B — virtual mode (preferred for large data)
gridControl.QueryCellInfo += (s, e) =>
{
if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex > 0)
e.Style.CellValue = $"{e.Cell.RowIndex}/{e.Cell.ColumnIndex}";
};
Common Patterns
Apply a Cell Type to a Range
// Set an entire column to CheckBox
for (int i = 1; i <= gridControl.Model.RowCount; i++)
gridControl.Model[i, 3].CellType = "CheckBox";
Alternate Row Colors via PrepareRenderCell
gridControl.PrepareRenderCell += (s, e) =>
{
if (e.Cell.RowIndex > 0 && e.Cell.RowIndex % 2 == 0)
e.Style.Background = Brushes.LightSkyBlue;
};
Freeze Header and Enable Formula Cells
gridControl.Model.FrozenRows = 1;
gridControl.Model.HeaderRows = 1;
gridControl.BaseStylesMap["Standard"].StyleInfo.CellType = "FormulaCell";
Export to Excel
gridControl.Model.ExportToExcel(@"Output.xlsx", ExcelVersion.Excel2007);
Key Style Properties
| Property |
Purpose |
Model[r, c].CellType |
Sets built-in or custom cell type string |
Model[r, c].CellValue |
Data value stored in the cell |
Model[r, c].Background |
Cell background brush |
Model[r, c].Foreground |
Cell text color |
Model[r, c].Font.FontSize |
Cell font size |
Model[r, c].Borders |
Individual border pens (Top/Bottom/Left/Right) |
Model[r, c].Format |
Format string (e.g., "C", "0.00", "d") |
Model.RowHeights[r] |
Row height in device-independent units |
Model.ColumnWidths[c] |
Column width |
Model.FrozenRows |
Number of rows frozen at top |
Model.FrozenColumns |
Number of columns frozen at left |
1---2name: syncfusion-wpf-excel-like-grid3description: Complete guide for implementing the Syncfusion WPF GridControl — an Excel-like, cell-based virtual grid for Windows Presentation Foundation applications. Use this when working with WPF GridControl or Syncfusion grid components, including cell types, virtual grids, formula cells, clipboard operations, and Excel import/export. Covers QueryCellInfo events, GridStyleInfo, GridModel, row/column management, and appearance customization for desktop applications.4---56# Implementing Syncfusion WPF GridControl78The Syncfusion WPF **GridControl** is a high-performance, cell-oriented grid that functions as a9flexible tabular display engine. It makes no assumptions about data structure, supports virtual10(on-demand) data loading via `QueryCellInfo`, and provides Excel-like behaviors including formulas,11import/export, clipboard operations, covered cells, and 20+ built-in cell types.1213## When to Use This Skill1415- Adding a GridControl to a WPF application (XAML or code-behind)16- Populating cells via direct assignment or the virtual `QueryCellInfo` event17- Configuring cell types (CheckBox, ComboBox, DateTimeEdit, FormulaCell, etc.)18- Customizing cell appearance (background, font, borders, data formats)19- Managing rows and columns (insert, remove, move, freeze, hide)20- Clipboard, undo/redo, and editing behavior21- Interactive features: drag-drop columns, cell drag-drop, resizing22- Formula cell support and the built-in formula library23- Exporting grid data to Excel; importing Excel workbooks into the grid24- Selection modes, events, and virtual mode patterns25- Performance tuning, virtualization, covered ranges, zooming26- Advanced features: comments, tooltips, printing, serialization, autofit2728## Documentation and Navigation Guide2930### Getting Started31📄 **Read:** [references/getting-started.md](references/getting-started.md)32- Required assembly references33- Adding GridControl via designer or programmatically34- Setting `RowCount` and `ColumnCount`35- Populating data by loop vs. `QueryCellInfo` virtual event36- Minimal working example3738### Cell Types39📄 **Read:** [references/cell-types.md](references/cell-types.md)40- 20+ built-in cell types: Header, Static, CheckBox, Button, Image, ComboBox,41 DropDownList, DateTimeEdit, IntegerEdit, DoubleEdit, CurrencyEdit, PercentEdit,42 MaskEdit, UpDownEdit, RichText, DataBoundTemplate, NestedGrid (ScrollGrid)43- Setting `Style.CellType` on individual cells or ranges44- ComboBox with `ChoiceList` vs. `ItemsSource`45- Custom cell types (CellModel + CellRenderer pattern)4647### Appearance and Styling48📄 **Read:** [references/appearance-and-styling.md](references/appearance-and-styling.md)49- `GridStyleInfo` class and style inheritance hierarchy50- Volatile vs. render cell styles51- Base styles (`BaseStylesMap`), TableStyle, RowStyles, ColumnStyles52- Background (solid/gradient), Foreground, Font, text orientation, borders53- Numeric and DateTime format strings; `FormatProvider` interface5455### Managing Rows and Columns56📄 **Read:** [references/managing-rows-and-columns.md](references/managing-rows-and-columns.md)57- Setting row/column counts and default sizes58- Hiding and unhiding rows/columns (`SetHidden`)59- Freezing rows/columns; footer and header rows/columns60- Inserting, moving, and removing rows/columns at runtime61- Resize behavior and disabling resize controllers6263### Editing, Clipboard, and Undo/Redo64📄 **Read:** [references/editing-clipboard-undo.md](references/editing-clipboard-undo.md)65- `CopyPasteOption` flags (CopyText, CopyCellData, PasteCell, CutCell, XmlCopyPaste)66- `TextDataExchange` for custom delimiters and buffer-based operations67- Clipboard events and `IGridCopyPaste` custom implementation68- `CommandStack`: Undo/Redo, `BeginTrans`, `CommitTrans`, `Rollback`69- Creating derived commands for extended undo/redo7071### Interactive Features72📄 **Read:** [references/interactive-features.md](references/interactive-features.md)73- Column drag-drop (`AllowDragColumns`)74- Excel-like cell drag-drop (`AllowDragDrop`, `DataObjectConsumerOptions`)75- Runtime row/column resizing and disabling resize controllers76- Hide/unhide rows and columns visually (`HiddenBorderBrush`, `SetHidden`)7778### Formula Cells79📄 **Read:** [references/formula-cells.md](references/formula-cells.md)80- Enabling `FormulaCell` type for individual cells or the entire grid81- Built-in formula library (150+ functions: Sum, Avg, Sqrt, Pow, Cos, Sin, etc.)82- Arithmetic operators and calculation precedence83- Cross-cell references (A1 notation), named ranges84- Adding custom formula functions to the library8586### Excel Import and Export87📄 **Read:** [references/excel-import-export.md](references/excel-import-export.md)88- Required assemblies (`Syncfusion.XlsIO`, `Syncfusion.GridConverter.Wpf`)89- Exporting entire or selected grid content to .xls / .xlsx90- Importing Excel workbooks: styles, formulas, conditional formatting, freeze panes,91 hyperlinks, comments92- Virtualized import for large workbooks9394### Selection and Events95📄 **Read:** [references/selection-and-events.md](references/selection-and-events.md)96- Selection modes: cell, row, column (`AllowSelection` flags)97- `QueryCellInfo` event pattern for virtual data loading98- `PrepareRenderCell` for view-specific overrides99- Common grid events: `CommitCellInfo`, `CurrentCellActivated`, clipboard events,100 `RowsInserted`, `ColumnsMoved`, `ResizingRows`, etc.101- Working with `GridRangeInfo` and `SelectedRanges`102103### Performance and Virtualization104📄 **Read:** [references/performance-virtualization.md](references/performance-virtualization.md)105- Virtual mode fundamentals and `QueryCellInfo` best practices106- Covered ranges (`CoveredCells`) and floating cells107- Zooming the grid108- High-frequency update patterns109110### Advanced Features111📄 **Read:** [references/advanced-features.md](references/advanced-features.md)112- Cell comments, input-message tips, and tooltips113- Cell layout customization (covered cells, merged ranges, autofit)114- Printing grid content115- Serialization: saving and loading grid state116- Autofit rows and columns to content117118## Quick Start Example119120```csharp121 1. Add assemblies: 122 Syncfusion.Grid.Wpf123 Syncfusion.GridCommon.Wpf,124 Syncfusion.Linq.Base, 125 Syncfusion.Shared.Wpf126127 // 2. XAML — place GridControl inside a ScrollViewer128<ScrollViewer>129 <syncfusion:GridControl x:Name="gridControl" />130</ScrollViewer>131132// 3. Code-behind: set size and populate133gridControl.Model.RowCount = 100;134gridControl.Model.ColumnCount = 10;135136// Option A — direct assignment137for (int i = 0; i < 100; i++)138 for (int j = 0; j < 10; j++)139 gridControl.Model[i, j].CellValue = $"{i}/{j}";140141// Option B — virtual mode (preferred for large data)142gridControl.QueryCellInfo += (s, e) =>143{144 if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex > 0)145 e.Style.CellValue = $"{e.Cell.RowIndex}/{e.Cell.ColumnIndex}";146};147```148149## Common Patterns150151### Apply a Cell Type to a Range152```csharp153// Set an entire column to CheckBox154for (int i = 1; i <= gridControl.Model.RowCount; i++)155 gridControl.Model[i, 3].CellType = "CheckBox";156```157158### Alternate Row Colors via PrepareRenderCell159```csharp160gridControl.PrepareRenderCell += (s, e) =>161{162 if (e.Cell.RowIndex > 0 && e.Cell.RowIndex % 2 == 0)163 e.Style.Background = Brushes.LightSkyBlue;164};165```166167### Freeze Header and Enable Formula Cells168```csharp169gridControl.Model.FrozenRows = 1;170gridControl.Model.HeaderRows = 1;171gridControl.BaseStylesMap["Standard"].StyleInfo.CellType = "FormulaCell";172```173174### Export to Excel175```csharp176gridControl.Model.ExportToExcel(@"Output.xlsx", ExcelVersion.Excel2007);177```178179## Key Style Properties180181| Property | Purpose |182|---|---|183| `Model[r, c].CellType` | Sets built-in or custom cell type string |184| `Model[r, c].CellValue` | Data value stored in the cell |185| `Model[r, c].Background` | Cell background brush |186| `Model[r, c].Foreground` | Cell text color |187| `Model[r, c].Font.FontSize` | Cell font size |188| `Model[r, c].Borders` | Individual border pens (Top/Bottom/Left/Right) |189| `Model[r, c].Format` | Format string (e.g., `"C"`, `"0.00"`, `"d"`) |190| `Model.RowHeights[r]` | Row height in device-independent units |191| `Model.ColumnWidths[c]` | Column width |192| `Model.FrozenRows` | Number of rows frozen at top |193| `Model.FrozenColumns` | Number of columns frozen at left |194````