[ Download Code Sample ]
Often the need arises to be able to group data in a DataGrid under subheadings. I will discuss and demonstrate three methods wth which to achieve grouping and subheadings in a DataGrid.
-
After the DataGrid has been populated, the column with the group names is updated so that each group name spans all corresponding rows.
-
Before the DataGrid has been populated, the data source is manipulated to add extra rows to act as subheadings.
-
While the DataGrid is being populated, an extra subheading row is added each time the value of the group name column changes.
With the first option, the resulting table would resemble the following:
With the second and third options, the resulting table would resemble the following: