DataColChanged事件中的代码,如果要用按钮实现,如何改写呢
If e.DataCol.Name = "品名" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("单价") = Nothing '那么清空此行单价列的内容
Else
Dim dr As DataRow
'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr = DataTables("产品").Find("[品名] = '" & e.NewValue & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
e.DataRow("单价") = dr("单价")
End If
End If
End If