# Creating a Hierarchical Display Manually

Learn how to programmatically create a hierarchical display with custom SheetView objects in this tutorial. Explore the example code for creating parent-child relations and assigning child sheets to parent rows.

## Content

You can manually (programmatically) create a hierarchical display as shown in the example below. The parent is the higher level of the hierarchy and the child is the lower level.

## Example

This example creates two custom **SheetView** objects: one as the parent and one as the child. In the parent sheet, the example overrides the [ChildRelationCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.ChildRelationCount.html) property and [GetChildView](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.GetChildView.html) and [FindChildView](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.FindChildView.html) methods. The **ChildRelationCount** is how many relations between this object and children objects (usually this is one).
The **GetChildView** is used to get the child sheet. It calls **FindChildView** to see if the sheet is already created. If it is, then use that sheet. If it is not, create a new child sheet.
The [SheetName](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.SheetName.html) property of the child **SheetView** determines which parent row it is assigned to.
Override the [ParentRowIndex](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.ParentRowIndex.html) property in the child **SheetView** to return the row number that child is assigned to. The **SheetName** in creating this sheet determines this number.

```vbnet
...
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
     fpSpread1.Sheets.Clear()
     fpSpread1.Sheets.Add(New customSheet)
     fpSpread1.Sheets(0).RowCount = 10
     Dim i As Integer
     For i = 0 To 9
          If i <> 1 Then
               fpSpread1.Sheets(0).SetRowExpandable(i, False)
          End If
     Next i
End Sub
End Class

Public Class customSheet
Inherits FarPoint.Win.Spread.SheetView

  Public Overrides ReadOnly Property ChildRelationCount() As Integer
     Get
          Return 1
     End Get
  End Property

  Public Overrides Function GetChildView(ByVal row As Integer, ByVal relationIndex As Integer) As FarPoint.Win.Spread.SheetView
     Dim child As customChild = CType(FindChildView(row, 0), customChild)
     If Not (child Is Nothing) Then Return child
          child = New customChild
          child.RowCount = 5
          child.Parent = Me
          child.SheetName = row.ToString
          ChildViews.Add(child)
     Return child
  End Function

  Public Overrides Function FindChildView(ByVal row As Integer, ByVal relationIndex As Integer) As FarPoint.Win.Spread.SheetView
     Dim id As String = row.ToString
     Dim View As FarPoint.Win.Spread.SheetView
     For Each View In ChildViews
          If View.SheetName = id Then Return View
     Next
     Return Nothing
  End Function
End Class

Public Class customChild
Inherits FarPoint.Win.Spread.SheetView
   Public Overrides ReadOnly Property ParentRowIndex() As Integer        Get             Return CInt(SheetName)
      End Get
   End Property
End Class
```

## See Also

[Creating Custom Hierarchy Icons](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-data-binding/spwin-databind-hierarchy/spwin-customhiearicons)