设置表B的DataColChanging事件:
Select Case e.DataCol.Name Case "租户编号","交租月份" Dim dr As DataRow dr = e.DataTable.Find("租户编号 = '" & e.DataRow("租户编号") & "' And 交租月份 = '" & e.DataRow("交租月份") & "'") If dr IsNot Nothing Then MessageBox.Show("存在重复月份") e.Cancel = True End IfEnd Select