俺喜欢用filler,简单好读。
按钮一代码:
DataTables("表B").DataRows.Clear
Dim ss As List(of String) = DataTables("表A").GetUniqueValues("","组别")
Dim f As New Filler
For Each s As String In ss
f.SourceTable = DataTables("表A")
f.SourceCols = "姓名"
f.DataTable = DataTables("表B")
f.DataCols = "组别_" & s
f.Filter = "组别='" & s & "'"
f.Append = False
f.Fill()
Next
MainTable = Tables("表B")
按钮二代码:
DataTables("表C").DataRows.Clear
Dim f As New Filler
f.SourceTable = DataTables("表A")
f.SourceCols = "工位"
f.DataTable = DataTables("表C")
f.DataCols = "工位"
f.Fill()
DataTables("表C").DataCols("工位").RaiseDataColChanged
MainTable = Tables("表C")
表C“DataColChanged”
If e.DataCol.Name = "工位"
Dim ss As List(of String) = DataTables("表A").GetUniqueValues("","组别")
For Each s As String In ss
Dim dr As DataRow = DataTables("表A").Find("工位='" & e.DataRow("工位") & "' and 组别='" & s & "'")
If dr IsNot Nothing
If e.DataRow.IsNull("工位")
e.DataRow("组别_" & s) = Nothing
Else
e.DataRow("组别_" & s) = dr("姓名")
End If
End If
Next
End If
[此贴子已经被作者于2013-7-31 15:42:30编辑过]