ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Tutorial 17 - Grouping Display

In this tutorial, you will learn how to use the DataView property to create a Grouping area above the grid, which enables the user to sort the data by columns at run time.

1.   Start with the project created in Tutorial 1 - Binding True DBGrid to a DataSet.

2.   Add the following code to the Load event of Form1 after the current DataAdapter code:

·      Visual Basic

Me.C1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy

·      C#

this.C1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy;

·      Delphi

Self.C1TrueDBGrid1.DataView := C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy;

Run the program and observe the following:

·      C1TrueDBGrid1 displays the data specified in Tutorial 1 - Binding True DBGrid to a DataSet.

·      Notice that there is a grouping section above the grid now.

·      Click on the Country column header and drag it into the grouping area. Your grid should now look like the following:

·      Notice that the C1TrueDBGrid has placed all of the members of the Country class into the left column and each row has an expand icon. Clicking on the expand icon will show you the data for every composer born in this country. 

·      Now drag the Last column header into the grouping area, then click on the expand icon next to Germany. Notice that the data is first sorted by country, then sorted by the last name of the composer. Clicking on the expand icon for one of the composers under last will bring up the remaining columns of data:

This concludes the tutorial.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.