假定表A有个逻辑列,希望在某行选中此逻辑列时,自动将此行复制到表(事件汇总)。
表A的“轻度”为整数列,在表A的DataColChanged事件代码设置为:
If e.DataCol.Name = "选择" Then
Dim dr As DataRow = e.DataRow
If dr("选择") = True And dr("轻度") > 0 Then
Dim dt As DataTable = DataTables("事件汇总")
Dim ndr As DataRow
Dim n As Integer = dr("轻度")
ndr = dt.AddNew(n)
For Each dr1 As DataRow In dt.DataRows
If dr1.RowState = DataRowState.Added Then
dr1("译码日期") = dr("译码日期")
dr1("性质") = "轻度"
End If
Next
End If
End If
表A另有“严重”列也为整数列,想重复以上操作,该如何精简地写代码?谢谢