以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  传递数据与同步删除请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96463)

--  作者:douglas738888
--  发布时间:2017/2/21 14:51:00
--  传递数据与同步删除请教

请教老师,下面的代码是把表A某列数据传递到表B某列,但是如果表A删除一行后,在datatchanged不触发遍历,表B接收表A传递过来的数据不同步,除非表A单元格内的数据变化,表B数据才会变化

 

如何实现,表A的遍历数据与表B同步?

 

If e.DataCol.Name = "配件名称" 
    Dim pdr As DataRow = DataTables("表B").find("系统编号 = \'" & e.DataRow("系统编号") & "\'")     

    If pdr IsNot Nothing Then
        Dim str As String = ""
        For Each dr As DataRow In DataTables("表A").Select("系统编号 = \'" & e.DataRow("系统编号") & "\'") 
            str & = dr("配件名称") & vbcrlf
        Next
        pdr("配件名称") = str
    End If
End If


--  作者:有点色
--  发布时间:2017/2/21 15:20:00
--  

 删除事件那里,DataRowDeleting事件

 

Dim pdr As DataRow = DataTables("表B").find("系统编号 = \'" & e.DataRow("系统编号") & "\'")

If pdr IsNot Nothing Then
    Dim str As String = ""
    For Each dr As DataRow In DataTables("表A").Select("系统编号 = \'" & e.DataRow("系统编号") & "\' and _Identify <> " & e.DataRow("_Identify"))
        str & = dr("配件名称") & vbcrlf
    Next
    pdr("配件名称") = str
End If