|
首先CustomizationListNode的children属性返回一个ilist接口,借口内包含了此节电下面的所有的子接点,此时,你可以通过一个 帝归的函数来便利整个CustomizationListNode,下面是一个例子,具体的关于其中个变量的定义可以参看需求
req对象中的节点的遍历,原理是一样的
sub ma(byval sunod as CustomizationListNode)
for each a in list
if a.list =null then
return
else
ma(a)
end if
next list
下面的是一段遍历测试需求树的代码,功能是按 cmdLoadReq按钮后,系统开始加载
td库中的所有测试需求,这两段代码是相通的req他也是通过一个Reqf.NewList("")返回一个ilist列表,然后再进行处理的
Public tdCN As New TDConnection
Public Reqf As ReqFactory
Public ReqList As List
Public ReqChildList As List
Public Req As Req
Public CurrentReq As String
Private Sub cmdLoadReq_Click()
cmdLoadReq.Enabled = False
Set Reqf = tdCN.ReqFactory
Set ReqList = Reqf.NewList("")
frmProject!TreeView1.LineStyle = tvwRootLines
frmProject!TreeView1.Nodes.Clear
For Each Req In ReqList
'Debug.Print req.Path
If CheckFold(Req.Path) Then
If Req.Path = "测试用例库\IVR与SSP之间的消息跟踪功能" Then
Debug.Print "a"
End If
frmProject!TreeView1.Nodes.Add , , "req" & Trim(Str(Req.ID)), Req.Name
'frmProject!TreeView1.Nodes.Add "req" & Trim(Str(req.ID)), 4, "r", req.Name
frmProject!TreeView1.Refresh
Debug.Print "req" & Trim(Str(Req.ID))
CreatReq Req.ID, Req.ID
End If
Next Req
Set ReqList = Nothing
cmdLoadReq.Enabled = True
End Sub
Public Sub CreatReq(ByVal reqId As String, ByVal oldReqId As String)
Dim tempReqList As List
Dim tempReqf As ReqFactory
Dim tempChildList As List
Dim tempReq As Req
Dim t As Integer
Dim Nods As Node
Dim tempListItem As ListItem
DoEvents
Set tempReqf = tdCN.ReqFactory
Set tempReqList = Reqf.GetChildrenList(reqId)
For Each tempReq In tempReqList
If Req.Path = "测试用例库\IVR与SSP之间的消息跟踪功能" Then
Debug.Print "a"
End If
If tempReq.Count <> 0 Then
t = t + 1
Debug.Print tempReq.Path
Set Nods = frmProject!TreeView1.Nodes.Add("req" & Trim(Str(reqId)), tvwChild, "req" & Trim(Str(tempReq.ID)), tempReq.Name)
CreatReq tempReq.ID, reqId
End If
If t > 5 Then
Exit Sub
End If
Next tempReq
End Sub |
|