Foxtable(狐表)用户栏目专家坐堂 → 取得父节点编号以及节点路径全名


  共有9668人关注过本帖树形打印复制链接

主题:取得父节点编号以及节点路径全名

帅哥哟,离线,有人找我吗?
狐狸爸爸
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/7/30 12:01:00 [显示全部帖子]

你要怎么显示? 我没有看明白你的问题。

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/7/31 12:05:00 [显示全部帖子]

很简单,你删除totalcpno和FindFather两列的内容,然后在命令窗口执行下面的代码看看:

 

For Each dr1 As DataRow  In DataTables("data").Select("","sortkey")
    Dim idx As Integer = dr1("sortkey").LastIndexof("\")
    If idx < 0 Then
        dr1("totalcpno") = dr1("cpno")
        dr1("FindFather") = Nothing
    Else
        Dim pkey As String = dr1("sortkey").Substring(0,idx)
        dr1("FindFather") = pkey
        Dim dr2 As DataRow = DataTables("data").Find("sortkey = '" & pkey & "'")
        If dr2 IsNot Nothing
            dr1("totalcpno") = dr2("totalcpno") & "\" & dr1("cpno")
        Else
            dr1("totalcpno") = "输入错误"
        End If
    End If
Next


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/7/31 12:09:00 [显示全部帖子]

如果你要自动,在DatacolChanged事件设置代码:

 

Select Case e.DataCol.name
    Case "cpno","sortkey"
        Dim dr1 As DataRow = e.DataRow
        Dim idx As Integer = dr1("sortkey").LastIndexof("\")
        If idx < 0 Then
            dr1("totalcpno") = dr1("cpno")
            dr1("FindFather") = Nothing
        Else
            Dim pkey As String = dr1("sortkey").Substring(0,idx)
            dr1("FindFather") = pkey
            Dim dr2 As DataRow = DataTables("data").Find("sortkey = '" & pkey & "'")
            If dr2 IsNot Nothing
                dr1("totalcpno") = dr2("totalcpno") & "\" & dr1("cpno")
            Else
                dr1("totalcpno") = "输入错误"
            End If
        End If
End Select


 回到顶部