datacolchanging事件
If e.DataCol.Name = "名称" Then Dim dr As DataRow dr = e.DataTable.Find("名称 = '" & e.NewValue & "' and 时间 = #" & e.DataRow("时间") & "#") If dr IsNot Nothing Then MessageBox.Show("此时间已存在相同名称!") e.Cancel = True End If End If