Row Grouping in 10Tec WinForms Grid

(iGrid.NET Control Tour, Step 5 of 9)

10Tec WinForms grid control provides you with 2 ways of row grouping - automatic row grouping and manual group row creation. Both approaches imply that group rows are added to the grid, and they can be nested to each other meaning lower position in hierarchy. The optional plus/minus buttons inside group rows are used to collapse/expand them.

Automatic row grouping

You can group rows automatically by the values of any column when you drag and drop the column's header into the iGrid.NET group box. The corresponding group rows are created in this case by iGrid automatically:

Example of automatic row grouping

The same operation can be implemented from code using the special GroupObject and the Group method of our WinForms grid.

Note that the columns you group by and other columns from the grid can be sorted while the grid is grouped. Any number of columns can be involved into sorting (multi-column sort).

Manual group rows

An automatic group row in iGrid has a special vertical band attached to it below at the left. This band is used as a helper area to show what rows are included into a particular group, and our WinForms grid even allows you to colorize this area with different colors for different levels of hierarchy.

The main difference between the automatic and manual group rows is that the manual group rows do not have this band. One of the main usages of this feature is another visual representation of row sections with similar contents. The following screenshot demonstrates how we use manual group rows in the iGrid.NET Demo application to organize samples:

Group rows created manually

As the name implies, manual group rows can be created only manually from code. They can be helpful in many cases when you want to control when and where group rows should appear, and what contents they should have. For instance, you can create custom subtotal rows with the help of manual group rows like we demonstrate in the next section of this page.

Emulation of DataGridView with subtotal rows

We position our iGrid.NET as a cheap and powerful replacement for the .NET DataGridView control. DataGridView does not support row grouping and subtotal rows for group rows. 10Tec iGrid.NET can be used to emulate DataGridView with subtotal rows:

Subtotal rows in a DataGridView-like grid

The ready-to-use source code of a similar functionality can be found in the iGrid.NET Extra Sample Library. The 'Subtotal Manager with Export to MS Excel' sample demonstrates how to enable switching of subtotals look from in-cell view to plain string view, when totals are displayed in group-row-like rows.

Emulating Outlook datagrid »