ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Tutorial 16 - Hierarchical Display

In this tutorial, you will learn how to display Master Detail DataSet information through the grid’s hierarchical display. This tutorial is similar to Tutorial 3 - Linking Multiple True DBGrid Controls, but this tutorial displays the same master detail information as Tutorial 3 - Linking Multiple True DBGrid Controls, except it only uses on True DBGrid object.

1.   Start by setting up a form with a grid and Master Detail DataSet by following the steps in Tutorial 3 - Linking Multiple True DBGrid Controls.

2.   In the Properties window, set the DataSource property of the grid to dsMasterDetail and the DataMember property to Composer.

3.   Next in the Load event of Form1 add the following code, which fills both the DataAdapters and sets the grid’s display to hierarchical:

·      Visual Basic

Me.ComposerTableAdapter.Fill(Me.DsMasterDetail.Composer)

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

·      C#

this.ComposerTableAdapter.Fill(this.DsMasterDetail.Composer);

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

·      Delphi

Self.ComposerTableAdapter.Fill(Self.DsMasterDetail.Composer)

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

Run the program and observe the following:

·      C1TrueDBGrid1 displays the Composers table as it would if it were bound to it, but each row has an expand icon. Expand one of the rows. Notice that the associated Opus column data is displayed in the far columns of the grid. The data showing relates to the record in the Composers table that was expanded:

This concludes the tutorial.


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