以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [讨论]  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=54519)

--  作者:rophy0952
--  发布时间:2014/7/30 9:08:00
--  [讨论]
欲在1-10列的数值变化时,合计也随着变化。
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140730090401.jpg
图片点击可在新窗口打开查看
在表事件的datacolchanged中所写的代码:

Dim sts() As String = {"分切净重_1","分切净重_2","分切净重_3","分切净重_4","分切净重_5","分切净重_6","分切净重_7","分切净重_8","分切净重_9","分切净重_10"}
For Each st As String In sts
If e.DataCol.name = st Then
    Dim dr As DataRow = e.DataRow
    dr("分切净重_合计") = dr("分切净重_1")+dr("分切净重_2")+dr("分切净重_3")+dr("分切净重_4")+dr("分切净重_5")+dr("分切净重_6")+dr("分切净重_7")+dr("分切净重_8")+dr("分切净重_9")+dr("分切净重_10" )
End If
Next

但提示出错!

--  作者:Bin
--  发布时间:2014/7/30 9:15:00
--  
select case e.DataCol.name
      case "分切净重_1","分切净重_2","分切净重_3","分切净重_4","分切净重_5","分切净重_6","分切净重_7","分切净重_8","分切净重_9","分切净重_10"
           Dim dr As DataRow = e.DataRow
    dr("分切净重_合计") = dr("分切净重_1")+dr("分切净重_2")+dr("分切净重_3")+dr("分切净重_4")+dr("分切净重_5")+dr("分切净重_6")+dr("分切净重_7")+dr("分切净重_8")+dr("分切净重_9")+dr("分切净重_10" )
end slect

--  作者:有点甜
--  发布时间:2014/7/30 9:17:00
--  
Dim sts() As String = {"分切净重_1","分切净重_2","分切净重_3","分切净重_4","分切净重_5","分切净重_6","分切净重_7","分切净重_8","分切净重_9","分切净重_10"}
Dim dr As DataRow = e.DataRow
Dim sum As Double = 0
For Each st As String In sts
    sum += dr(st)
Next
dr("分切净重_合计") = sum

--  作者:rophy0952
--  发布时间:2014/7/30 9:59:00
--  
问题已解决,谢谢!