在父表的DataColChanged事件里输入的代码是
If e.DataCol.Name = "布料编号" Then ‘’这里判断的是父表的列
If e.DataRow.IsNull("布料编号") = False
e.DataRow("已裁数1") = DataTables("总计划布料需求1").Compute("sum(已裁数1)","布料编号1='" & e.NewValue & "'")
End If
End If
在子表的DataColChanged事件里输入的代码是
If e.DataCol.Name = "布料编号1" Then ‘’这里判断的是子表的列
If e.DataRow.IsNull("布料编号1") = False
Dim dr As DataRow = DataTables("总计划布料需求汇总表").Find("布料编号='" & e.NewValue & "'")
If dr Is Nothing Then
dr = DataTables("总计划布料需求汇总表").AddNew
dr("布料编号") = e.NewValue
End If
DataTables("总计划布料需求汇总表").DataCols("布料编号").RaiseDataColChanged(dr)
End If
ElseIf e.DataCol.Name = "已裁数1" Then
Dim dr As DataRow = DataTables("总计划布料需求汇总表").Find("布料编号='" & e.DataRow("布料编号1") & "'")
If dr IsNot Nothing Then
DataTables("总计划布料需求汇总表").DataCols("布料编号").RaiseDataColChanged(dr)
End If
End If