为了达到以上两种功能,我分别在datachaning中添加了下面的代码
Select Case e.DataCol.Name
Case "年度"
If e.NewValue<> e.OldValue AndAlso e.NewValue > "" AndAlso e.OldValue > "" Then
Dim nb As DataRow = e.DataTable.AddNew
For Each dc As DataCol In e.DataTable.DataCols
If dc.name = "年度" Then
nb("年度") = e.NewValue
Else
nb(dc.Name) = e.DataRow(dc.Name)
End If
Next
e.cancel = True
End If
End Select
在datachanged中添加了下面的代码:
Select Case e.DataCol.name
Case "年度","编号"
Dim dr As DataRow = e.DataRow
If dr.IsNull("年度") = False AndAlso dr.IsNull("编号") = False Then
If e.DataTable.Compute("Count([_Identify])","年度 = '" & dr("年度") & "' And 编号 = '" & dr("编号") & "'") > 1 Then
MessageBox.Show("已经存在相同数据的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.DataRow.delete()
End If
End If
End Select
在窗口afterload中添加下面代码:
If CurrentTable.Name = "录入窗口_Table1" Then
For Each c As Winform.Control In e.Form.Controls
If c.Bindingfield > "" AndAlso c.Bindingfield.StartsWith("shzz.") Then
c.BindingField = c.BindingField.Replace("shzz.", "录入窗口_Table1.")
End If
Next
End If
现在的问题是通过以操作,出现了以下问题:
1、当我在窗口talbe中点击数据时,数据不能即时显示在窗口中
2、当我输入重复的年度值时,如果存在编号0211的两个不同年度值时(比如2010、2011),它会删除到只剩下一个年度的值