Private Sub Form_Load()
'引用C:\windows\system32\MSCOMCTL.OCX,否则提示出错。
Dim Rec As New ADODB.Recordset
Dim stRecQL As String
Dim Item As Integer
Dim i As Integer
Dim Node1 As Node
Rec.Open "tblTreeview", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
For i = 0 To Rec.RecordCount - 1
If Rec!parentid = "S0000" Then
Set Node1 = Me.TreeView0.Nodes.Add(, , "S" & Rec!ID, Rec!ChildID)
Else
Set Node1 = Me.TreeView0.Nodes.Add("S" & Rec!parentid, tvwChild, "S" & Rec!ID, Rec!ChildID)
'Node1.index = True
End If
Rec.MoveNext
Next
For i = 1 To TreeView0.Nodes.Count
TreeView0.Nodes(i).Expanded = True '展开所有节点
Next i
Rec.Close
End Sub