DataColChanged事件,如下代码
If e.DataCol.Name.StartsWith("开piao日期") AndAlso e.DataCol.Name.EndsWith("日期") AndAlso e.NewValue <> Nothing Then
Dim sum As Integer = 0
For i As Integer = 1 To 3
Dim count As Integer = e.DataTable.Compute("count(_Identify)", "开piao日期" & i & "_日期 = #" & e.NewValue & "# and 开piao人信息_姓名 = '" & e.DataRow("开piao人信息_姓名") & "'")
sum += count
Next
If sum >= 7 Then
msgbox(e.NewValue & "超过7张")
e.DataRow(e.DataCol.Name) = Nothing
End If
End If