Articles in this section
Category / Section

How to access the nested tables in the WinForms GridGroupingControl?

1 min read

Access the nested tables

You can get access to a nested table inside a record using the following code example. In the following code example, you can get the specific record, or you can get all the records through the Records collection of the nested table.

C#

private void button1_Click(object sender, EventArgs e)
{
   //You can get access to a nested table inside a record whereas n is the specific record that owns the nested table.
   NestedTable nt = this.gridGroupingControl1.Table.Records[3].NestedTables[0];
   ChildTable ct = nt.ChildTable;
   //To get access to a specific record in that child table
   Record recordInNestedTable = ct.Records[3];
   //To get access to all records in that child table
   foreach (Record rec in ct.Records)
   {
      // this.richTextBox1.Text += rec.ToString();
      //[or]
      this.richTextBox1.Text += rec.GetValue("childID") + "\t" + rec.GetValue("Name").ToString() + "\n";
   }
}

VB

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
   'You can get access to a nested table inside a record whereas n is the specific record that owns the nested table.
   Dim nt As NestedTable = Me.gridGroupingControl1.Table.Records(3).NestedTables(0)
   Dim ct As ChildTable = nt.ChildTable
   'To get access to a specific record in that child table
   Dim recordInNestedTable As Record = ct.Records(3)
   'To get access to all records in that child table
   For Each rec As Record In ct.Records
      ' this.richTextBox1.Text += rec.ToString();
      '[or]
      Me.richTextBox1.Text += rec.GetValue("childID") + Constants.vbTab + rec.GetValue("Name").ToString() & Constants.vbLf
   Next rec
End Sub

The access to the third record in the child table is displayed as follows.

Access the nested tables in WinForms GridGroupingControl

Samples:

C#: Access_NestedTables

VB: Access_NestedTables

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied