Foxtable(狐表)用户栏目专家坐堂 → 请教目录树问题


  共有1565人关注过本帖平板打印复制链接

主题:请教目录树问题

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


加好友 发短信
等级:幼狐 帖子:185 积分:1526 威望:0 精华:0 注册:2017/7/23 17:17:00
请教目录树问题  发帖心情 Post By:2017/9/26 8:46:00 [只看该作者]

本人通过人员表,生成某加载树
Dim cmb1 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim ryxxb As DataTable
cmd.C
cmd.CommandText="select * f rom  v_OA_a01 where 部门名称 like 'TZXJ%'"
ryxxb=cmd.ExecuteReader
Tables("员工表_ryxxb").DataSource =ryxxb
cmb1.ComboList=ryxxb.GetComboListString("工号")


Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(ryxxb,"部门名称|姓名")
trv.Nodes.Insert("全部",0)


想选取目录树某几行的时候,在表里选择相应的人员
For Each nd As WinForm.TreeNode In e.node.AllNodes  '同步子节点选中状态
    If nd.FullPath.StartsWith(e.node.FullPath) Then
        nd.Checked = e.node.Checked
    End If
Next
If e.node.Checked = False Then '如果本次操作为清除节点选中状态
    Dim pd As WinForm.TreeNode = e.node.ParentNode '获取父节点
    Do While pd IsNot Nothing
        pd.Checked = False '清除父节点选中状态
        pd  = pd.ParentNode '继续获取上一层级的父节点
    Loop
End If

Dim cmd As new SQLCommand
Dim ryxxb As DataTable
cmd.C
Dim Filter As String
Dim gh As String
If e.node.Text = "全部" Then
    cmd.CommandText="select * f rom  v_OA_a01 where 部门名称 like 'TZXJ%'"
Else
    Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
    Dim dr As DataRow
    For Each nd As WinForm.TreeNode In trv.AllNodes
        dr=nd.DataRow
                If  nd.Checked = True Then
                    gh=gh & "'" & dr("工号") & "',"
                End If
    Next
  gh=gh.Trim(",")
  MessageBox.show(gh)
  If gh>"" Then
  cmd.CommandText="select * fr om  v_OA_a01 where 工号 in (" & gh & ")"
  Else
  cmd.CommandText="select * fr om  v_OA_a01"
   End If
End If

ryxxb=cmd.ExecuteReader
Tables("员工表_ryxxb").AutoSizeCols
Tables("员工表_ryxxb").DataSource =ryxxb

问题有二:
一、我这样设计是否合理
二、当我在目录树选择一个或几个人的时候,右边会出现相应的人员了,但是当我去掉所有选择的时候,报错
.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2017.6.12.1
错误所在事件:窗口,员工表,TreeView1,AfterCheckNode
详细错误信息:
未将对象引用设置到对象的实例。

请指教

 回到顶部