If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then
Dim nma() As String = {"型号","规格","A3","A4"} 'A表数据来源列
Dim nmb() As String = {"型号","规格","B3","B4"} 'B表数据接收列
Dim dr As DataRow = DataTables("表B").AddNew
For i As Integer = 0 To nma.Length - 1
dr(nmb(i)) = e.DataRow(nma(i))
Next
End If
用上面的代码,下面的代码失效,如何解决?
Select Case e.DataCol.name
Case "型号","规格"
Dim xh As String
Dim gg As String
If e.DataCol.Name= "型号" Then
xh = e.NewValue
gg = e.DataRow("规格")
Else
gg = e.NewValue
xh = e.DataRow("型号")
End If
If xh > "" AndAlso gg > "" Then
Dim dr As DataRow = e.DataRow
If e.DataTable.Find("型号 = '" & xh & "' And 规格 = '" & gg & "'") IsNot Nothing Then
MessageBox.Show("已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
End Select