lpp56 发表于 2005-9-5 18:42:47

关于CustomizationListNode子节点的获得

首先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

sincky 发表于 2005-9-6 12:44:20

好例子!

lpp56 发表于 2005-9-6 13:50:38

对上面例子的说明

例子中的这一段没有什么意义,是我在调试的时候,为了避免死循环加入的
If t > 5 Then
            Exit Sub
End If
上面的功能就是实现在TREEVIEW控件中加载所有的TD中测试需求的项目

okby 发表于 2006-6-15 14:54:57

这样的比较深入经验,还是少了。多谢楼主。
TD二次开发功能蛮强大的

i1521 发表于 2007-11-20 16:34:01

这个功能是否可引申到列表自动列表的变动呢?
比如,用户,用户太多的时候很难选,如果只选择如属于开发组的用户,则少多了

要是能实现这个功能,无疑,td的易用易操作性前进了一大步啊
页: [1]
查看完整版本: 关于CustomizationListNode子节点的获得