表B DataColChanged
Select Case e.DataCol.Name Case "数量" Dim pdr As DataRow = e.DataRow.GetParentRow("表A") If pdr IsNot Nothing Dim yl As Double = pdr("总数量") - pdr("已出数量") '计算剩余可以开piao的数量 If yl < 0 Then msgbox("超出") Else pdr("余量") = yl End If End IfEnd Select