表A,DataColChanged事件代码:
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "关联列"
If dr.IsNull("关联列") Then
dr("地址") = Nothing
dr("联系电话") = Nothing
Else
Dim dr2 As DataRow = DataTables("表B").Find("[关联列] = '" & e.NewValue & "'")
If dr2 IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
dr("地址") = dr2("地址")
dr("联系电话") = dr2+("联系电话")
End If
End If
End Select
[此贴子已经被作者于2019/3/23 9:44:02编辑过]