老师,没报错,就是不执行
If e.DataCol.Name = "货名" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("料号") = Nothing '那么清空此行单价列的内容
e.DataRow("料名") = Nothing
e.DataRow("用量") = Nothing
Else
'Dim dr As DataRow
''否则在产品表查找同名的产品行,将找到的行赋值给变量dr
'dr = DataTables("表B").Find("[货名 = '" & e.NewValue & "'")
Dim Cols1() As String = {"货号","品名","料号","料名","用量"}
Dim Cols2() As String = {"货号","品名","料号","料名","用量"}
For Each dr1 As DataRow In DataTables("表B").Select("[货名 = '" & e.NewValue & "'")
Dim dr2 As DataRow = DataTables("表C").AddNew()
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
dr2("数量") = e.DataRow("数量")
Next
End If
End If