Select Case e.DataCol.name
Case "年月"
If e.NewValue <> nothing AndAlso e.DataRow.IsNull("姓名") = False
Dim dr As DataRow = e.DataRow
If e.DataTable.Find("年月 = '" & e.NewValue & "' And 姓名 = '" & dr("姓名") & "'") IsNot Nothing Then
MessageBox.Show("已经存在相同年月和姓名的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
Case "姓名"
If e.newvalue <> nothing AndAlso e.DataRow.IsNull("年月") = False
Dim dr As DataRow = e.DataRow
If e.DataTable.Find("年月 = '" & dr("年月") & "' And 姓名 = '" & e.NewValue & "'") IsNot Nothing Then
MessageBox.Show("已经存在相同年月和姓名的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
End Select