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 automatic group rows are created in this case by iGrid:
The same operation can be implemented from code using the special
GroupObject and the
Group method of our DataGridView-like control.
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
Automatic group rows in iGrid have a special vertical band attached to it at the left and below. This band is used as a helper area to see 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:
As the name implies, manual group rows can be created only manually from code. They can be helpful in many other cases.
For instance, you can create custom subtotal rows with the help of them. We position our iGrid.NET as a cheap and powerful replacement for the DataGridView control, and our grid does not implement creation of subtotal rows as a built-in feature because of this. However, this does not mean you cannot have them at all. You can - due to the rich extensibility model of our WinForms grid, and below is a picture of subtotal rows in our DataGridView-like control:
Another source code sample of this called Subtotal Manager with Export to MS Excel can be found in the iGrid.NET Extra Sample Library.