|
2#
楼主 |
发表于 2007-10-25 16:59:17
|
只看该作者
代码如下
Private Sub Form_Load()
Dim objNode As Node
Dim Rst As DAO.Recordset
Dim strID As String
Dim MaxLevel As Integer
Dim I As Integer
Set objTree = Me.TreeView0.Object
objTree.Nodes.Clear
Set objNode = objTree.Nodes.add(, , "NO.1", "建筑定额") ' 头
MaxLevel = CurrentDb.OpenRecordset("SELECT 等级 FROM 章节表 order by 等级 desc;")(0).Value
For I = 1 To MaxLevel
Set Rst = CurrentDb.OpenRecordset("SELECT 等级,ID,章节名称 FROM 章节表 where 等级=" & I & ";")
Do Until Rst.EOF
If Rst!等级 = 1 Then '顶层菜单
Set objNode = objTree.Nodes.add("NO.1", 5, "NO." & Trim(Rst!ID), Trim(Rst!章节名称))
Else
Set objNode = objTree.Nodes.add("NO." & Left(Rst!ID, (Rst!等级 - 1) * perSectionLong), 5, "NO." & Trim(Rst!ID), Trim(Rst!章节名称))
End If
Rst.MoveNext
Loop
Next
Call TreeView0_NodeClick(objTree.Nodes(1))
End Sub |
|