Foxtable(狐表)用户栏目专家坐堂 → 通用多选目录树加载代码


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

主题:通用多选目录树加载代码

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


加好友 发短信
等级:四尾狐 帖子:810 积分:5250 威望:0 精华:0 注册:2009/2/6 10:38:00
通用多选目录树加载代码  发帖心情 Post By:2013/3/22 9:33:00 [显示全部帖子]

 把大家的成果集中在一起,发上来共享,以感谢各位的帮助知道。

 

Dim Lbs As String() ={"产品","客户","雇员","折扣","日期"}  '通用多选目录树加载代码.套用时只需修改本行.

Dim trv As WinForm.TreeView = e.Sender

Dim nd As WinForm.TreeNode = trv.SelectedNode

Dim flt,s1 As String

Dim n1 As Integer

 

For Each ndx As WinForm.TreeNode In nd.allNodes '同步子节点选中状态

    ndx.Checked = nd.Checked

Next

If nd.ParentNode IsNot Nothing Then     '确定父节点选中状态:

    For i As Integer = nd.ParentNode.level To 0 Step -1   '

        Dim Inum As Integer = nd.ParentNode.Nodes.Count

        For Each ndc As WinForm.TreeNode In nd.ParentNode.Nodes

            If ndc.Checked Then

                Inum = Inum -1

            End If

        Next

        If Inum = 0 Then

            nd.ParentNode.Checked = True

            nd = nd.ParentNode

        Else

            nd.ParentNode.Checked = False

            nd = nd.ParentNode

        End If

    Next

End If

For Each nd In trv.AllNodes

    If nd.Level > 0 AndAlso nd.ParentNode.Checked Then '如果父节点选中

        Continue For '跳过此节点,处理下一结点

    End If

    If nd.Checked AndAlso nd.FullPath IsNot Nothing Then

        n1=0

        For Each s1 In nd.FullPath.split("\")

            flt+ =iif(n1 =0,") Or (" ," and ")  & Lbs(n1) & " = '" & s1 & "'"

            n1+=1

        Next

    End If

Next

Application.DoEvents  '先勾选目录树,再加载数据.

If  flt  IsNot Nothing  Then

    Tables("订单").DataTable.LoadFilter = flt.Substring(4) & ")"

    Tables("订单").DataTable.Load()

Else

    Tables("订单").DataTable.LoadFilter ="[_Identify] Is Null"

    Tables("订单").DataTable.Load()

End If

 



 回到顶部