|
8#
楼主 |
发表于 2003-11-19 23:28:00
|
只看该作者
在下面的函数中用DAO进行查询得到相应的记录,再用ADD方法。增加NODE。
Private Sub GetFunctionList()
' 初始化 FunctionList 树
On Error GoTo Tree_Fill_Err
Dim rs As DAO.Recordset
Dim strSQL As String
Dim nodeCurrent As Node
Dim strFID, strPID As String
Dim imgID As Integer
strSQL = "Select * from MISFunctionList Where LN='CN' Order By ParentID,ID"
Set rs = CurrentDb().OpenRecordset(strSQL)
If Not rs.BOF Then
rs.MoveFirst
End If
tvFunctionList.Nodes.Clear
Do While Not rs.EOF
strFID = "NO" + CStr(rs("ID"))
strPID = "NO" + CStr(rs("arentID"))
imgID = Nz(rs("Type"), 0)
If rs("ID") = 0 Then
tvFunctionList.Style = 3
Set nodeCurrent = tvFunctionList.Nodes.Add(, tvwFirst, strFID, rs("Name"), imgID, imgID + 1)
Else
tvFunctionList.Style = 7
Set nodeCurrent = tvFunctionList.Nodes.Add(strPID, tvwChild, strFID, rs("Name"), imgID, imgID + 1)
End If
nodeCurrent.Tag = Nz(rs("FCode"), "")
rs.MoveNext
Loop
If tvFunctionList.Nodes.Count > 1 Then
tvFunctionList.Nodes(2).Expanded = True
End If
Function_Exit:
rs.Close
Set rs = Nothing
Exit Sub
Tree_Fill_Err:
DoErr (Err.Number)
End Sub |
|