36楼都说了,要加上必要的判断
......
Dim sum As Decimal = 0
Dim hs As Long = 0
For Each p As String In _ps
Dim ary() As String = p.Split(",")
If ary.Length = 2 Then
If e.Table.Cols(CInt(ary(1))).IsNumeric Then
If ary(0) >= 0 AndAlso ary(1) >= 0 AndAlso e.Table.Rows(ary(0), True).IsGroup = False Then
Dim s As C1.Win.C1FlexGrid.CellStyle = e.Table.grid.Styles.Add("selected")
's.backcolor = Color.LightSteelBlue '背景
s.backcolor = Color.LightBLue
e.Table.Grid.SetCellStyle(ary(0)+e.Table.HeaderRows, ary(1)+1, s)
'e.Table.DataTable.SysStyles("Focus").BackColor = Color.red
'各种计算
Dim cval = e.Table(cint(ary(0)), cint(ary(1)))
sum += val(cval)
hs = hs + 1
End If
End If
End If
Next
If hs > 0 Then
StatusBar.Message1 = "第" & (e.Table.Position + 1) & "行,目前展现" & e.Table.Rows.Count & "行,本表共" & e.Table.DataTable.DataRows.Count & "行." & _
"| |计数:" & hs & " |累计:" & sum & " |平均:" & sum/hs
Else
StatusBar.Message1 = "第" & (e.Table.Position + 1) & "行,目前展现" & e.Table.Rows.Count & "行,本表共" & e.Table.DataTable.DataRows.Count & "行."
End If