如何给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";//设置为小数点后两位
}
}

posted on 2019-06-12 17:25  AbelAngelo  阅读(523)  评论(0编辑  收藏  举报

导航