The cell-oriented grid control is a very efficient display engine for tabular data that can be customized down to the cell level. It does not make any assumptions about the structure of the data. It can be used in a virtual manner where the data is provided on demand in real time, or it can be used in a manner where the grid control maintains the data within its own internal structures. The grid control supports frozen rows and columns, Excel-like formulas, covered cells, various cell-control types, copy–paste, both row selections and cell-range selections, hidden rows and columns, and a virtually unlimited number of rows and columns.
There are two modes for populating the grid control with data (cell values and the required cell styles). You can use its internal data storage or provide the data on demand through virtualization. To use the grid control’s internal data storage, you can simply set the cell styles using the grid indexer. To configure the grid control in virtual mode, you need to dynamically provide data to the grid through an event, which means that the grid does not store any data in its internal data structures. A virtual grid can display millions of rows as easily as it displays a dozen. The grid also exposes a second event that lets you save changes made through the grid’s UI back to the external data source.
The grid control supports styles to change the appearance of an individual or a group of cells, rows, and columns. Common style properties include options to change background color, text color, font, alignment, wrap text mode, orientation, border, and various cell formats including date-time, currency, numeric and text formats, Excel-like cell comments, etc. You can apply a single background across multiple cells using the cell spanning feature.
The grid control supports several cell types including text box, combo box, check box, button, numeric spin box, drop-down list, embedded grid cells, and editor types like masked edit, double edit, integer edit, percent edit, and date-time edit. In addition, you can place any WPF control or any custom control inside a cell using the DataTemplate cell type.
Covered cells allow you to treat a rectangular collection of cells as a single cell. A covered cell is treated as a normal cell to which you can apply all the usual style properties.
The grid control provides various row and column options such as interactive column rearranging with drag-and-drop operations, hide or unhide a range of rows and columns, resize the row heights and column widths to fit the cell contents, and options to fix rows and columns to the left, right, top, or bottom of the grid control that are similar to freeze panes in Excel.
The grid control offers different kinds of selection modes such as row only, column only, cell only, or any combination of rows, columns, and cells. Selection rendering is done on a separate layer from the grid rendering, thereby providing superior performance.
The grid control provides extensive support for keyboard handling, including all the popular Excel keyboard shortcuts. Arrow keys move the current cell, Ctrl+arrow keys move to first/last row/column, Shift+arrow keys select the cells, Delete deletes the cell contents, Page Up and Page Down scroll the grid by pages, F2 activates or deactivates the current cell, F4+Alt drops-down or closes-up the pop-up in a cell, Ctrl+X, Ctrl+V, Ctrl+C, Insert for common clipboard operations. All keyboard operations are customizable.
The undo and redo commands add immeasurable value to the user interface of any application. The grid control offers complete support for multilevel undo and redo operations. Any changes to the grid are saved in an undo list to perform subsequent undo and redo operations when needed. A group of such actions, called a ‘transaction,’ can be rolled back in a single step.
The grid control supports Excel-like formulas in each cell. It comes with an extensive formula function library that supports more than 360 built-in formulas. You can also easily add custom functions to its function library.
The grid control supports Excel-like user interaction features such as cell range drag-and-drop, autofill selections, and visual indicators to show hidden rows and columns. It also provides an Excel-like current cell for editing. Content in a rich text box cell can be copied and pasted from the grid control to Microsoft Excel. The following clipboard operations are supported: cutting, copying, or pasting text only; cutting, copying, or pasting text and styling; skipping a current cell while performing clipboard operations; copying cells from the grid control to Microsoft Excel while inheriting basic formatting like foreground, background, font style and size, and formulas.
The import feature allows you to import an Excel workbook to a grid while preserving the workbook’s look and feel. The following can be imported: an entire spreadsheet, formulas, styles, conditional formats, frozen panes, backgrounds, foregrounds, comments.
The grid control provides excellent clipboard support that allows users to copy and paste grid cells. You can even copy and paste cell contents into Excel with the styles and formulas intact.
The grid control provides inherent support for exporting its content to an Excel file (.xls and .xlsx formats) and to .csv files. The formatting of rich content is also preserved when exporting to Excel.