如何给gridControl动态的添加合计

时间:2019-06-12
本文章向大家介绍如何给gridControl动态的添加合计,主要包括如何给gridControl动态的添加合计使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

for (int i = 0; i < this.dsHz.Tables[0].Columns.Count; i++)
{
if (dsHz.Tables[0].Columns[i].DataType == typeof(Int32) ||
dsHz.Tables[0].Columns[i].DataType == typeof(Double) ||
dsHz.Tables[0].Columns[i].DataType == typeof(Decimal))
{
this.gvHz.Columns[i].SummaryItem.DisplayFormat = "{0:C}";//设置显示格式
this.gvHz.Columns[i].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;//设置显示类型
}
//当类型为double和Decimal类型时,设置 其精度
if (dsHz.Tables[0].Columns[i].DataType == typeof(Double) || dsHz.Tables[0].Columns[i].DataType == typeof(Decimal))
{
this.gvHz.Columns[i].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
this.gvHz.Columns[i].DisplayFormat.FormatString = "0.00";//设置为小数点后两位
}
}

原文地址:https://www.cnblogs.com/AbelAngelo/p/11010982.html