C1FlexGrid的SubTotal函数
来源:互联网 发布:阿里云os 系统精简 编辑:程序博客网 时间:2024/06/03 01:42
flex.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Clear); for (int c = 0; c < flex.Cols.Count; c++) { if (c < flex.Cols.Fixed || flex.Cols[c].DataType == typeof(System.String) || flex.Cols[c].DataType == typeof(System.DateTime) || flex.Cols[c].DataType == typeof(System.Boolean) || flex.Cols[c].DataType == typeof(System.Byte) || flex.Cols[c].DataType == typeof(System.Char) || flex.Cols[c].DataType == typeof(System.SByte) || flex.Cols[c].DataType == typeof(System.Object)) continue; flex.Subtotal(AggregateEnum.Sum, 0, -1, c, "合计"); if (flex.Cols[c] != null && (flex.Cols[c].DataType == typeof(System.Int32) || flex.Cols[c].DataType == typeof(System.Decimal))) { decimal de = string.IsNullOrEmpty(Convert.ToString(flex.GetData(flex.Rows.Count - 1, c))) ? 0 : Convert.ToDecimal(flex.GetData(flex.Rows.Count - 1, c)); flex.SetData(flex.Rows.Count - 1, c, de.ToString("0.00")); } } flex.SubtotalPosition = SubtotalPositionEnum.BelowData; CellStyle s = flex.Styles[CellStyleEnum.Subtotal0]; s.BackColor = Color.White; s.ForeColor = Color.Red; flex.Tree.Column = 1;