Foxtable(狐表)用户栏目专家坐堂 → 逻辑列自动复制行问题,请教老师们


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

主题:逻辑列自动复制行问题,请教老师们

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


加好友 发短信
等级:四尾狐 帖子:824 积分:6294 威望:0 精华:0 注册:2012/3/1 3:17:00
逻辑列自动复制行问题,请教老师们  发帖心情 Post By:2012/11/18 22:44:00 [只看该作者]

看了帮助文件中的逻辑列“自动复制行”,有点疑惑,如果接收数据的是2张表呢?代码该怎么写比较简洁?以下是帮助文件中的代码,请教老师们

If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then
    Dim nma() As String = {"A1","A2","A3","A4"}
'A表数据来源列

   
Dim nmb() As String = {"B1","B2","B3","B4"} 'B表数据接收列
   
Dim dr As DataRow = DataTables("表B").AddNew
   
For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
   
Next
End
If


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


加好友 发短信
等级:小狐 帖子:359 积分:3403 威望:0 精华:0 注册:2011/8/2 20:53:00
  发帖心情 Post By:2012/11/19 9:07:00 [只看该作者]

If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then Dim nma() As String = {"A1","A2","A3","A4"} 'A表数据来源列 Dim nmb() As String = {"B1","B2","B3","B4"} 'B表数据接收列 Dim nmc() As String = {"B1","B2","B3","B4"} 'B表数据接收列 Dim dr As DataRow = DataTables("表B").AddNew Dim cr As DataRow = DataTables("表C").AddNew For i As Integer = 0 To nma.Length - 1 dr(nmb(i)) = e.DataRow(nma(i)) cr(nmc(i)) = e.DataRow(nma(i)) Next End If 这样试试

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/11/19 9:08:00 [只看该作者]

一样:

 

 

If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then
    Dim nma() As String = {"A1","A2","A3","A4"} 'A表数据来源列
    Dim nmb() As String = {"B1","B2","B3","B4"} 'B表和C表数据接收列
    Dim dr1 As DataRow = DataTables("表B").AddNew
    Dim dr2 As DataRow = DataTables("表C").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr1(nmb(i)) = e.DataRow(nma(i))
        dr2(nmb(i)) = e.DataRow(nma(i))
    Next
End If


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


加好友 发短信
等级:四尾狐 帖子:824 积分:6294 威望:0 精华:0 注册:2012/3/1 3:17:00
  发帖心情 Post By:2012/11/19 19:26:00 [只看该作者]

感谢老爹跟Kevin的帮助,尝试了下表C接收的列设置2列时出现错误,代码为:

If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then
    Dim nma() As String = {"A1","A2","A3","A4"} 'A表数据来源列
    Dim nmb() As String = {"B1","B2","B3","B4"} 'B表数据接收列
    Dim nmc() As String = {"B1","B2"} 'C表数据接收列
    Dim dr As DataRow = DataTables("表B").AddNew
    Dim cr As DataRow = DataTables("表C").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
        cr(nmc(i)) = e.DataRow(nma(i))
    Next
End If

 

再请教个问题,自动复制行中三表的列数是不是需要一样?


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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/11/19 20:43:00 [只看该作者]

如果长度不一致,要分开写才行:

 

 

If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then
    Dim nma() As String = {"A1","A2","A3","A4"} 'A表数据来源列
    Dim nmb() As String = {"B1","B2","B3","B4"} 'B表数据接收列
    Dim nmc() As String = {"B1","B2"} 'C表数据接收列
    Dim dr As DataRow = DataTables("表B").AddNew
    Dim cr As DataRow = DataTables("表C").AddNew
    For i As Integer = 0 To nmb.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
    For i As Integer = 0 To nmc.Length - 1
        cr(nmc(i)) = e.DataRow(nma(i))
    Next
End If


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


加好友 发短信
等级:四尾狐 帖子:824 积分:6294 威望:0 精华:0 注册:2012/3/1 3:17:00
  发帖心情 Post By:2012/11/20 0:57:00 [只看该作者]

图片点击可在新窗口打开查看终于弄明白了,感谢老爹

 

 


 回到顶部