I have tried to fix it as follows:
procedure TNextGrid.AddChildRow(const Index: Integer; Position: TChildRowPosition); var Pos, Col: Integer; begin case Position of crFirst: Pos := Index + 1; // else Pos := Index + Row[Index].ChildCount + 1; else Pos := Index + Row[Index].FamilyCount + 1; end;
and adding this new property FamilyCount to the TRow class (see attached file).
PS. "OffspringCount" maybe is a more accurate variable name...?