I have the following code which populates a treeview. It is 5 layers deep. I have subclassed the treenode (cTreenode) as I need various bits of info on each node later.
This works but it takes 50 Secs with the amount of info I have at the mo. I need it to be quicker. Anybody any ideas??

Thanks in advance.

Dim oDVProvider As New DataView(oDS.Tables("DefaultTable"))
Dim oDRowProvider As DataRowView
Static iProvIndex As Int32 = -1, iContIndex As Int32 = -1, iServIndex As Int32 = -1, iPropIndex As Int32 = -1, iClientIndex As Int32 = -1
'Add the row filter
oDVProvider.RowFilter = "TYPE = 'Provider'"
oDVProvider.Sort = "LINEDESC"

For Each oDRowProvider In oDVProvider
Dim oProvNode() As cTreeNode
iProvIndex += 1
ReDim Preserve oProvNode(iProvIndex)
oProvNode(iProvIndex) = New cTreeNode(globals.Catergories.Provider, CType(oDRowProvider.Item("LINEDESC"), String), CType(oDRowProvider.Item("LINEID"), Int32), 0, 0, CType(oDRowProvider.Item("LINEEXTRA"), String))
'Add to root of tree
tvwMain.Nodes.Add(oProvNode(iProvIndex))

'Add Contracts
Dim oDVContract As New DataView(oDS.Tables("DefaultTable"))
Dim oDRowContract As DataRowView
Dim sContractFilter As String = "PARENTID = '" & CType(oDRowProvider.Item("PKID"), String) & "'"
oDVContract.RowFilter = sContractFilter
oDVContract.Sort = "LINEDESC"
For Each oDRowContract In oDVContract
Dim oContNode() As TreeNode
iContIndex += 1
ReDim Preserve oContNode(iContIndex)
oContNode(iContIndex) = New cTreeNode(globals.Catergories.Contract, CType(oDRowContract.Item("LINEDESC"), String), CType(oDRowContract.Item("LINEID"), Int32), 1, 1)
'add to parent
oProvNode(iProvIndex).Nodes().Add(oContNode(iContIndex))

' Add Service
Dim oDVService As New DataView(oDS.Tables("DefaultTable"))
Dim oDRowService As DataRowView
Dim sServiceFilter As String = "PARENTID = '" & CType(oDRowContract.Item("PKID"), String) & "'"
oDVService.RowFilter = sServiceFilter
oDVService.Sort = "LINEDESC"
Dim iServNo As Int32 = 0
For Each oDRowService In oDVService
Dim oServNode() As TreeNode
iServIndex += 1
ReDim Preserve oServNode(iServIndex)
oServNode(iServIndex) = New cTreeNode(globals.Catergories.Service, CType(oDRowService.Item("LINEDESC"), String), CType(oDRowService.Item("LINEID"), Int32), 2, 2)
oContNode(iContIndex).Nodes().Add(oServNode(iServIndex))

'Add Property
Dim oDVProperty As New DataView(oDS.Tables("DefaultTable"))
Dim oDRowProperty As DataRowView
Dim sPropertyFilter As String = "PARENTID = '" & CType(oDRowService.Item("PKID"), String) & "'"
oDVProperty.RowFilter = sPropertyFilter
oDVProperty.Sort = "LINEDESC"
Dim iPropNo As Int32 = 0
For Each oDRowProperty In oDVProperty
Dim oPropNode() As TreeNode
iPropIndex += 1
ReDim Preserve oPropNode(iPropIndex)
oPropNode(iPropIndex) = New cTreeNode(globals.Catergories.Properties, CType(oDRowProperty.Item("LINEDESC"), String), CType(oDRowProperty.Item("LINEID"), Int32), 3, 3)
oServNode(iServIndex).Nodes().Add(oPropNode(iPropIndex))

'Add Client
Dim oDVClient As New DataView(oDS.Tables("DefaultTable"))
Dim oDRowClient As DataRowView
Dim sClientFilter As String = "PARENTID = '" & CType(oDRowProperty.Item("PKID"), String) & "'"
oDVClient.RowFilter = sClientFilter
oDVClient.Sort = "LINEDESC"
Dim iClientNo As Int32 = 0
For Each oDRowClient In oDVClient
Dim oClientNode() As TreeNode
iClientIndex += 1
ReDim Preserve oClientNode(iClientIndex)

oClientNode(iClientIndex) = New cTreeNode(globals.Catergories.Client, CType(oDRowClient.Item("LINEDESC"), String), CType(oDRowClient.Item("LINEID"), Int32), 4, 4)
oPropNode(iPropIndex).Nodes().Add(oClientNode(iClientIndex))
iClientNo = iClientNo + 1
Next
'Update Parent node with number of clients
oPropNode(iPropIndex).Text = oPropNode(iPropIndex).Text.ToString & " (" & iClientNo & ")"
iPropNo = iPropNo + 1
Next
oServNode(iServIndex).Text = oServNode(iServIndex).Text.ToString & " (" & iPropNo & ")"
iServNo = iServNo + 1
Next
oContNode(iContIndex).Text = oContNode(iContIndex).Text.ToString & " (" & iServNo & ")"
Next
Next