If e.DataCol.Name = "规格" Then '如果内容发生变动的是品名列 If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空 e.DataRow("件重") = Nothing '那么清空此行单价列的内容 Else Dim jz As DataRow '否则在产品表查找同名的产品行,将找到的行赋值给变量dr jz = DataTables("表A").Find("[规格] = '" & e.NewValue & "'") If jz IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing e.DataRow("件重") = jz("件重") End If End If End If