google搜索 51Testing站内搜索                    软件测试门户 | 软件测试培 训 | 文章资料精选 | 软件测试论坛 | 软件测试博客 | 测试招聘求职 
打印

关于CustomizationListNode子节点的获得

关于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

TOP

好例子!
为您提供软件测试免费职业咨询、软件测试高薪技能培训、软件测试人才免费推荐的一条龙服务!!!
联系msn:sinckyzhang@gmail.com
欢迎访问http://hr.51testing.com 国内第一个专业的软件测试领域人才招聘网站!企业招聘、个人求职全免费!

TOP

对上面例子的说明


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

TOP

这样的比较深入经验,还是少了。多谢楼主。
TD二次开发功能蛮强大的
诚信为先,坚持走自己的路

TOP

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

要是能实现这个功能,无疑,td的易用易操作性前进了一大步啊

TOP

 
当前时区 GMT+8, 现在时间是 2008-9-8 14:06Copyright(C)上海博为峰软件技术有限公司 2001-2007 电话:021-64471599-8017
当您在访问网站、论坛及博客过程中遇到问题时可发送email:webmaster@51testing.com或发送论坛短信至管理员风在吹