
Thank You Example I make this!!
I hope someOne found this useful
Private Sub Form_Load()
With TreeView1
.Style = tvwTreelinesPlusMinusPictureText
.LineStyle = tvwRootLines
.PathSeparator = "\"
.Indentation = Screen.TwipsPerPixelX * 5 '256
.LabelEdit = tvwManual
.SingleSel = False
.HideSelection = False
.ImageList = ImageList1
.Refresh
End With
Call ShowEstructure
End Sub
Private Sub ShowEstructure()
Dim i As Byte
Dim j As Byte
Dim k As Byte
Dim Max As Byte
Dim sp As String
Dim sh As String
Dim sh2 As String
Dim TotalSecciones As Byte
Dim TotalPosiciones As Byte
Dim rsSeccions As New ADODB.Recordset
Dim rsPositions As New ADODB.Recordset
TreeView1.Nodes.Clear
Set grsGral = New ADODB.Recordset
grsGral.Open "EXEC spSQL_ShowDepartments", gConnectionString, adOpenStatic, adLockReadOnly, 1
Max = grsGral.RecordCount
For i = 1 To Max
'Actual Node
sp = "nodo" & CStr(i)
TreeView1.Nodes.Add , , sp, grsGral.Fields(1).Value, 1
grsGral.MoveNext
Next
grsGral.MoveFirst
For i = 1 To Max
' leaf
sp = "nodo" & CStr(i)
Set rsSeccions = New ADODB.Recordset
rsSeccions.Open "EXEC spSQL_ShowSeccions_forThis '" & grsGral.Fields(0).Value & "'", gConnectionString, adOpenStatic, adLockReadOnly, 1
TotalSecciones = rsSeccions.RecordCount
For j = 1 To TotalSecciones
' relative son
sh = sp & "-" & CStr(j) 'j
TreeView1.Nodes.Add sp, tvwChild, sh, rsSeccions.Fields(0).Value, 2
'*-*-*-
Set rsPositions = New ADODB.Recordset
rsPositions.Open "EXEC spSQL_ShowPositions_forThis '" & rsSeccions.Fields(1).Value & "'", gConnectionString, adOpenStatic, adLockReadOnly, 1
TotalPosiciones = rsPositions.RecordCount
For k = 1 To TotalPosiciones
' La clave del nodo hijo, relativo al nodo sP
sh2 = sh & "-" & CStr(k) 'j
TreeView1.Nodes.Add sh, tvwChild, sh2, rsPositions.Fields(0).Value, 3
rsPositions.MoveNext
Next
Set rsPositions = Nothing
'*--*-*-
rsSeccions.MoveNext
Next
Set rsSeccions = Nothing
grsGral.MoveNext
Next
Set grsGral = Nothing
End Sub