1、禁止父行没有保存的时候增加子行,可以在子表的BeforeAddDataRow事件中写上代码:
Dim r As Row = Tables("父表").Current
If r Is Nothing OrElse r.DataRow.RowState <> DataRowState.Unchanged Then
e.cancel = True
End If
2、如果要一次处理一样,再加一点代码:
Dim r As Row = Tables("父表").Current
If r Is Nothing OrElse r.DataRow.RowState <> DataRowState.Unchanged Then
e.cancel = True
End If
If r IsNot Nothing Then
For Each dr As DataRow In r.DataRow.GetChildRows("子表") Then
If dr.RowState <> DataRowState.Unchanged Then
e.cancel = True
Exit For
End If
End If
End If