Set nodx = TreeView1.Nodes.Add(, , "r", "行业大类列表", 2)----这里是顶部
Set nodx = TreeView1.Nodes.Add("r", tvwChild, , mrc.Fields("class"), 1)----这里是下一级的节点
我已经循环从数据库中取出了这样的树状结构我现在的问题是Set nodx = TreeView1.Nodes.Add("r", tvwChild, , mrc.Fields("class"), 1)这里我循环取出了class的值之后怎么在这个节点下面增加他相应的子节点
数据库方面不用说。大家就告诉我一下怎么针对Set nodx = TreeView1.Nodes.Add("r", tvwChild, , mrc.Fields("class"), 1)这个代码能添加一个子节点就好了
谢谢大家。

解决方案 »

  1.   

    Set nodx = TreeView1.Nodes.Add("r", tvwChild, , mrc.Fields("class"), 1)…………………………………………………………………………………………
    这段代码是不是也在for循环中?
    这样子就不行了!~
      

  2.   

    Set nodx = TreeView1.Nodes.Add("r", tvwChild, , mrc.Fields("class"), 1)这个实在rs当中循环的德
      

  3.   

    给我写信,我有一个例子,也许对你有用[email protected]
      

  4.   

    这个很容易呀,,用SQL语句找出class下面的节点的数据不就行了吗?到时候添加就可以了。
      

  5.   

    说了等于没说
    思路我还知道也
    我现在就是不知道怎么给Set nodx = TreeView1.Nodes.Add("r", tvwChild, , mrc.Fields("class"), 1)这个节点增加子节点明白不?
      

  6.   

    RS.OPEN "SELECT * FROM TAB WHERE FIELD='" & mrc.Fields("class") & "'",,,
    DO WHILE RS.EOF
    Set nodx = TreeView1.Nodes.Add("class", tvwChild, ,RS.FIELD(0) , 1)
     RS.MOVENEXT
    NEXT
      

  7.   

    不要用Key值,用index添加比较牢靠
    我的方法是
    Set nodx = TreeView1.Nodes.Add(, , "r", "行业大类列表", 2)
    y=0
    do while not rs.eof
    Set nodx = TreeView1.Nodes.Add(TreeView1.Nodes.count-y, tvwChild, , rs.Fields("class"), 1)
    y=y+1
    loop这个方法只能在一个父Node加好后马上加他的子nodes如果你的层数很多的话要注意控制好数字,反正添加的总是最后一个算法解决好了就很简单
      

  8.   

    在定义第二个后加上:
    nodx.Key = "string as you will"
    Set nodx = TreeView1.Nodes.Add("string as you will", tvwChild, , "新值", 1)
      

  9.   

    说什么键值不唯一是什么意思我的代码是这样的TreeView1.Nodes.Clear
        TreeView1.ImageList = ImageList1
        Dim nodx As Node 'treeview的节点对象
        Dim nodx2 As Node
        Set nodx = TreeView1.Nodes.Add(, , "r", "行业大类列表", 2)
        tree_sql = "select class from CusTomer_Aclass order by id desc"
        Set mrc = ExecuteSQL(tree_sql, MsgText)
        If mrc.EOF Then
        Set nodx = TreeView1.Nodes.Add("r", tvwChild, , "当前还没有行业大类资料", 1)
        Else    mrc.MoveFirst
        Do While Not mrc.EOF
        AClass = mrc.Fields("class")
        Set nodx = TreeView1.Nodes.Add("r", tvwChild, , mrc.Fields("class"), 1)
        nodx.Key = "string as you will"
        Set nodx = TreeView1.Nodes.Add("string as you will", tvwChild, , "新值", 1)
        mrc.MoveNext
        Loop
        End If
        mrc.Close
        TreeView1.Nodes(1).Expanded = True
      

  10.   


        nodx.Key = "string as you will"
        Set nodx = TreeView1.Nodes.Add("string as you will", tvwChild, , "新值", 1)这里就说键值不唯一
      

  11.   

    每个子节点的key值不能一样,否则就会出错
      

  12.   

    Set nd = TreeView1.Nodes.add("ppl0key000", tvwChild, "p0l1key" & rs("id"), "(" & rs("code") & ")" & rs("name"), IIf(rs("man") = True, 1, 2))
      

  13.   

    Set rootnd = TreeView1.Nodes.Add(, , "ppl0key000", "长运集团有限公司")
    Set nd = TreeView1.Nodes.Add("ppl0key000", tvwChild, "p0l1key", "漳州")
    Set nd = TreeView1.Nodes.Add("ppl0key000", tvwChild, "p0l1keyA", "漳州AA")
    Set nd = TreeView1.Nodes.Add("p0l1keyA", tvwChild, "p0l1keyNNN", "高兴")