Foxtable(狐表)用户栏目专家坐堂 → 老师,还是一个目录树同步的问题


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

主题:老师,还是一个目录树同步的问题

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


加好友 发短信
等级:狐精 帖子:3205 积分:21305 威望:0 精华:0 注册:2016/3/28 16:57:00
老师,还是一个目录树同步的问题  发帖心情 Post By:2019/11/5 15:50:00 [显示全部帖子]

 新增节点后马上修改节点名称报错,如果是修改以前的节点就没问题。

 
此主题相关图片如下:qq截图20191105154957.png
按此在新窗口浏览图片

 


此主题相关图片如下:qq截图20191105154818.png
按此在新窗口浏览图片

 

导航表的 DataColChanged 事件代码如下:红色代码没执行

If e.DataCol.Name="分组"  Then
    Dim fn As winform.form=vars("editForm")
    If fn.Opened Then
        Dim tr As WinForm.TreeView = fn.Controls("TreeView1")
        For Each sd As  WinForm.TreeNode In tr.AllNodes
            If sd.Text = e.OldValue AndAlso sd.DataRow("子键")=e.DataRow("子键") Then
                sd.Text=e.NewValue

            End If
        Next
    End If
    Dim drs As List(Of  DataRow)
    drs = DataTables(vars("editTable")).Select("[分组] = '" & e.OldValue & "' and [子键] = '" & e.DataRow("子键") &  "'")
    For Each dr As DataRow In drs
        dr("分组") = e.NewValue
    Next
End If

If e.DataCol.Name="名称" Then
    Dim fn As winform.form=vars("editForm")
    If fn.Opened Then
        Dim tr As WinForm.TreeView = fn.Controls("TreeView1")
        For Each sd As  WinForm.TreeNode In tr.AllNodes
            If sd.Text = e.OldValue AndAlso sd.DataRow("序号")=e.DataRow("序号") Then
           msgbox(1)
                sd.Text=e.NewValue
           msgbox(2)
            End If
        Next
    End If
    Dim drs As List(Of  DataRow)
    drs = DataTables(vars("editTable")).Select("[名称] = '" & e.OldValue & "' and [序号] = '" & e.DataRow("序号") &  "'")
    For Each dr As DataRow In drs
        dr("名称") = e.NewValue
    Next
End If

 

  


[此贴子已经被作者于2019/11/5 15:51:57编辑过]

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


加好友 发短信
等级:狐精 帖子:3205 积分:21305 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2019/11/5 16:43:00 [显示全部帖子]

请老师看看,还是不对

If e.DataCol.Name="分类" OrElse e.DataCol.Name="分组" OrElse  e.DataCol.Name="名称"  Then
    Dim fn As winform.form=vars("editForm")
    If fn.Opened Then
        Dim tr As WinForm.TreeView = fn.Controls("TreeView1")
        For Each sd As  WinForm.TreeNode In tr.AllNodes
            Select Case sd.Level
                Case 0
                    Dim dr As DataRow = DataTables(vars("editTable")).Find("[分类] Like '%" & sd.Text & "' and 分组 is null")
                    If dr IsNot Nothing Then
                        If sd.Text = e.OldValue AndAlso dr("父键")=e.DataRow("父键")  Then
                        sd.Text= e.NewValue
                        End If
                    End If
                    Dim drs As List(Of  DataRow)
                    drs = DataTables(vars("editTable")).Select("[分类] = '" & e.OldValue & "' and [父键] = '" & e.DataRow("父键") &  "'")
                    For Each dr1 As DataRow In drs
                        dr1("分类") = e.NewValue
                    Next
                Case 1
                    Dim dr As DataRow = DataTables(vars("editTable")).Find("[分类] Like '%" & sd.parentnode.Text & "' and 分组 = '" & sd.Text & "' and 名称 is null")
                    If dr IsNot Nothing Then
                        If sd.Text = e.OldValue  AndAlso dr("子键")=e.DataRow("子键")  Then
                        sd.Text= e.NewValue
                        End If
                    End If
                    Dim drs As List(Of  DataRow)
                    drs = DataTables(vars("editTable")).Select("[分组] = '" & e.OldValue & "' and [子键] = '" & e.DataRow("子键") &  "'")
                    For Each dr2 As DataRow In drs
                        dr2("分组") = e.NewValue
                    Next
                Case 2
                    Dim dr As DataRow = DataTables(vars("editTable")).Find("[分类] Like '%" & sd.parentnode.parentnode.Text & "' and 分组 = '" & sd.parentnode.Text & "' and 名称 = '" & sd.Text & "'")
                    If dr IsNot Nothing Then
                        If sd.Text = e.OldValue AndAlso dr("序号")=e.DataRow("序号")  Then
                            sd.Text=e.NewValue
                        End If
                    End If
                    Dim drs As List(Of  DataRow)
                    drs = DataTables(vars("editTable")).Select("[名称] = '" & e.OldValue & "' and [序号] = '" & e.DataRow("序号") &  "'")
                    For Each dr3 As DataRow In drs
                        dr3("名称") = e.NewValue
                    Next
            End Select
        Next
    End If
End If

[此贴子已经被作者于2019/11/5 17:02:36编辑过]

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


加好友 发短信
等级:狐精 帖子:3205 积分:21305 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2019/11/5 17:14:00 [显示全部帖子]

.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2019.10.26.1
错误所在事件:表,导航,DataColChanged
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。

老师,报错,4就没出来!

 

 

If e.DataCol.Name="名称" Then
    Dim fn As winform.form=vars("editForm")
msgbox(1)
    If fn.Opened Then
        Dim tr As WinForm.TreeView = fn.Controls("TreeView1")
msgbox(2)
        Dim node As WinForm.TreeNode = tr.Nodes(e.DataRow("分类"))
msgbox(3)
        If node IsNot Nothing AndAlso node.Nodes.count > 0 Then
            node = node.Nodes(e.DataRow("分组"))
msgbox(4)

            If node IsNot Nothing AndAlso node.Nodes.count > 0  Then
                node = node.Nodes(e.OldValue)
msgbox(5)
                If node IsNot Nothing Then
                    node .Text=e.NewValue
msgbox(6)
                End If
            End If
        End If
    End If
msgbox(7)

[此贴子已经被作者于2019/11/5 17:17:21编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  4楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3205 积分:21305 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2019/11/6 9:30:00 [显示全部帖子]

老师,3后面的代码没执行,直接就报错,报错的原因好像是这样的:

 

 
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20191106095744.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2019/11/6 10:21:18编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  5楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3205 积分:21305 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2019/11/6 10:33:00 [显示全部帖子]

老师,数据正常了,在新增节点时,OldValue为空,还没有(node = node.Nodes(e.OldValue))这个节点,执行到6报这个错是什么原因?

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20191106102711.png
图片点击可在新窗口打开查看

 

msgbox(1)
        Dim s As String = e.DataRow("分类")
msgbox(2)
        Dim node As WinForm.TreeNode = tr.Nodes(s.trim())
msgbox(3)
        If node IsNot Nothing AndAlso node.Nodes.count > 0 Then
msgbox(4)
            node = node.Nodes(e.DataRow("分组"))
msgbox(5)
            If node IsNot Nothing AndAlso node.Nodes.count > 0  Then
msgbox(6)
                node = node.Nodes(e.OldValue)
msgbox(7)
                If node IsNot Nothing Then
msgbox(8)
                    node .Text=e.NewValue
msgbox(9)
                End If

[此贴子已经被作者于2019/11/6 10:47:36编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  6楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3205 积分:21305 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2019/11/6 13:25:00 [显示全部帖子]

谢谢老师指点,还是采用了我原来的方法,直接判断父节点是同一个分组,当分组时,判断父节点是同一个分类。

 

vars("editTable") ="导航"  '当前编辑的菜单数据表
Select Case e.DataCol.Name
    Case "分类"
        Dim fn As winform.form=vars("editForm")
        If fn.Opened Then
            Dim tr As WinForm.TreeView = fn.Controls("TreeView1")
            For Each sd As  WinForm.TreeNode In tr.AllNodes
                If sd.Text = e.OldValue Then
                    sd.Text=e.NewValue
                End If
            Next
        End If
        Dim drs As List(Of  DataRow)
        drs = DataTables(vars("editTable")).Select("[分类] = '" & e.OldValue & "'")
        For Each dr As DataRow In drs
            dr("分类") = e.NewValue
        Next
    Case "分组"
        Dim fn As winform.form=vars("editForm")
        If fn.Opened Then
            Dim tr As WinForm.TreeView = fn.Controls("TreeView1")
            For Each sd As  WinForm.TreeNode In tr.AllNodes
                'If sd.Text = e.OldValue  Then
                Dim  s As  String = e.DataRow("分类").Trim() '清除分类中的空格
                If sd.Text = e.OldValue  AndAlso sd.parentnode.Text= s Then
                    sd.Text=e.NewValue
                End If
            Next
        End If
        Dim drs As List(Of  DataRow)
        drs = DataTables(vars("editTable")).Select("[分组] = '" & e.OldValue & "' and [子键] = '" & e.DataRow("子键") &  "'")
        For Each dr As DataRow In drs
            dr("分组") = e.NewValue
        Next
    Case "名称"
        Dim fn As winform.form=vars("editForm")
        If fn.Opened Then
            Dim tr As WinForm.TreeView = fn.Controls("TreeView1")
            For Each sd As  WinForm.TreeNode In tr.AllNodes
                'If sd.Text = e.OldValue  Then
                If sd.Text = e.OldValue  AndAlso sd.parentnode.Text= e.DataRow("分组")  Then
                    sd.Text=e.NewValue
                End If
            Next
        End If
        Dim drs As List(Of  DataRow)
        drs = DataTables(vars("editTable")).Select("[名称] = '" & e.OldValue & "' and [序号] = '" & e.DataRow("序号") &  "'")
        For Each dr As DataRow In drs
            dr("名称") = e.NewValue
        Next
End Select


 回到顶部