那你就不能在datarowadded事件写代码,必须在DataColChanged事件写。
If e.DataCol.name = "项目id" Then
e.DataRow.save
systemready = False
Dim Cols1() As String ={"清单ID","单位工程","清单号","清单名称","单位","单价","数量","项目ID"}
Dim Cols2() As String ={"清单ID","单位工程","清单号","清单名称","单位","单价","数量","项目ID"}
For Each dr1 As DataRow In DataTables("清单").Select("项目ID= '" & e.DataRow("项目ID") & "'")
Dim dr2 As DataRow = DataTables("完成明细").find("项目ID= '" & dr1("项目ID") & "' and 清单id= '" & dr1("清单id") & "' and 统计id = " & e.DataRow("_Identify"))
If dr2 Is Nothing Then dr2 = DataTables("完成明细").AddNew()
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
dr2("统计id") = e.DataRow("_Identify")
Next
systemready = True
End If