|
5#
楼主 |
发表于 2012-6-26 17:15:56
|
只看该作者
我将程序发上来你看看,麻烦了。
Private Sub TreeviewLoad()
Set TreeView0.ImageList = ImageList.Object
Me.TreeView0.Nodes.Clear
Dim CONN As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSql As String
Dim nodIndex As Node
Set nodIndex = TreeView0.Nodes.Add(, , "根", "天然气输气工区", "K")
nodIndex.Sorted = True
nodIndex.Expanded = True
strSql = "SELECT DISTINCT 仪器仪表统计台帐.站名 From 仪器仪表统计台帐"
Set CONN = CurrentProject.Connection
CONN.CursorLocation = adUseClient
rs.Open strSql, CONN, adOpenKeyset, adLockOptimistic, adCmdTableDirect
Do Until rs.EOF = True
Set nodIndex = TreeView0.Nodes.Add("根", tvwChild, "干" & rs.Fields("站名"), rs.Fields("站名"), "K1", "K2")
nodIndex.Expanded = True
rs.MoveNext
Loop
rs.Close
strSql = "SELECT DISTINCT 仪器仪表统计台帐.站名,仪器仪表统计台帐.计量点名称 From 仪器仪表统计台帐"
rs.Open strSql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
Do Until rs.EOF = True
Set nodIndex = TreeView0.Nodes.Add("干" & rs.Fields("站名"), tvwChild, "枝" & rs.Fields("站名") & rs.Fields("计量点名称"), rs.Fields("计量点名称"), "K1", "K2")
'nodIndex.Expanded = True
rs.MoveNext
Loop
rs.Close
strSql = "SELECT * From 仪器仪表统计台帐"
rs.Open strSql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
Do Until rs.EOF = True
Set nodIndex = TreeView0.Nodes.Add("枝" & rs.Fields("站名") & rs.Fields("计量点名称"), tvwChild, "叶" & rs.Fields("站名") & rs.Fields("计量点名称") & rs.Fields("安装位置"), rs.Fields("安装位置"), "K1", "K2")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub |
|