datacolchanged事件
If e.DataCol.Name = "第五列" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("第一列") = Nothing '那么清空此行单价列的内容
e.DataRow("第二列") = Nothing '那么清空此行单价列的内容
e.DataRow("第三列") = Nothing '那么清空此行单价列的内容
e.DataRow("第四列") = Nothing '那么清空此行单价列的内容
Else
Dim dr As DataRow '否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr = DataTables("表A").Find("[第五列] = '" & e.NewValue & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
Dim fdr As DataRow
fdr = e.DataTable.Find("第一列 = '" & dr("第一列") & "'")
If fdr IsNot Nothing Then
For Each dc As DataCol In e.DataTable.datacols
If dc.Expression = "" Then
e.DataRow(dc.name)=Nothing
End If
Next
Else
e.DataRow("第一列") = dr("第一列")
e.DataRow("第二列") = dr("第二列")
e.DataRow("第三列") = dr("第三列")
e.DataRow("第四列") = dr("第四列")
End If
End If
End If
End If