這樣可以不必去掉數據中的『'』
一:按鈕
Dim T,Tj,T1,Ts As String
Dim Ls As List(Of String)
Dim dt As DataTable = DataTables("柜型")
For Each r As Row In Tables("统计").Rows
T = "关联 = " & r("_Identify")
Ls = dt.GetUniqueValues( T ,"柜型")
if Ls.count > 0 then
For Each T1 In Ls
Tj = T & " and 柜型 = '" & T1.Replace("'","''") & "'"
Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
Next
r("统计")=Ts.substring(1)
Ts =Nothing
end if
Next
二:DataColChanged事件
If e.DataCol.Name = "柜型" Then
Dim dr,pr As DataRow
dr = e.DataRow
pr = dr.GetParentRow("统计")
if pr isnot nothing then
Dim T,Tj,T1,Ts As String
Dim Ls As List(Of String)
Dim dt As DataTable = DataTables("柜型")
T = "关联 = " & dr("关联")
Ls = dt.GetUniqueValues( T ,"柜型")
For Each T1 In Ls
Tj = T & " and 柜型 = '" & T1.Replace("'","''") & "'"
Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
Next
pr("统计") =Ts.substring(1)
End If
End If
[此贴子已经被作者于2009-4-11 14:55:49编辑过]