Home Forums WinForms controls Xceed Grid for WinForms Building an unbound hierarchical master/detail grid Reply To: Building an unbound hierarchical master/detail grid

User (Old forums)
Member
Post count: 23064

The only other possibility is to add each row in the detail grid row by row for each parent row. But at the end, it is equivalent.

i.e. :

Dim mainRow As Xceed.Grid.DataRow = grid.DataRows.AddNew()
mainRow.Cells(“FirstName”).Value = “Peter”
mainRow.Cells(“LastName”).Value = “Griffin”
mainRow.Cells(“FamilyID”).Value = 1
mainRow.Cells(“Occupation”).Value = “Fisherman”
mainRow.EndEdit()

mainRow = grid.DataRows.AddNew()
mainRow.Cells(“FirstName”).Value = “Homer”
mainRow.Cells(“LastName”).Value = “Simpson”
mainRow.Cells(“FamilyID”).Value = 2
mainRow.Cells(“Occupation”).Value = “Nuclear Technician”
mainRow.EndEdit()

Dim subRow = grid.DataRows[ 0 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Lois”
subRow.Cells(“Relationship”).Value = “Wife”
subRow.Cells(“FamilyID”).Value = 1
subRow.EndEdit()

subRow = grid.DataRows[ 0 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Meg”
subRow.Cells(“Relationship”).Value = “Daughter”
subRow.Cells(“FamilyID”).Value = 1
subRow.EndEdit()

subRow = grid.DataRows[ 0 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Chris”
subRow.Cells(“Relationship”).Value = “Son”
subRow.Cells(“FamilyID”).Value = 1
subRow.EndEdit()

subRow = grid.DataRows[ 0 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Stewie”
subRow.Cells(“Relationship”).Value = “Son”
subRow.Cells(“FamilyID”).Value = 1
subRow.EndEdit()

subRow = grid.DataRows[ 0 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Brian”
subRow.Cells(“Relationship”).Value = “Dog”
subRow.Cells(“FamilyID”).Value = 1
subRow.EndEdit()

subRow = grid.DataRows[ 1 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Marge”
subRow.Cells(“Relationship”).Value = “Wife”
subRow.Cells(“FamilyID”).Value = 2
subRow.EndEdit()

subRow = grid.DataRows[ 1 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Bart”
subRow.Cells(“Relationship”).Value = “Son”
subRow.Cells(“FamilyID”).Value = 2
subRow.EndEdit()

subRow = grid.DataRows[ 1 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Lisa”
subRow.Cells(“Relationship”).Value = “Daughter”
subRow.Cells(“FamilyID”).Value = 2
subRow.EndEdit()

subRow = grid.DataRows[ 1 ].DetailGrids[ 0 ].DataRows.AddNew();

subRow.Cells(“FirstName”).Value = “Maggie”
subRow.Cells(“Relationship”).Value = “Daughter”
subRow.Cells(“FamilyID”).Value = 2
subRow.EndEdit()

Imported from legacy forums. Posted by André (had 3116 views)