DevExpress.XtraGrid.Views.Grid.GridView汇总显示3,4个小数

来源:互联网 发布:模板小偷帝国cms 编辑:程序博客网 时间:2024/05/20 06:05

第一步:

注册事件

gridView.CustomDrawFooterCell += new DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventHandler(GridViewMain_CustomDrawFooterCell);

第二步:

重写事件

void GridViewMain_CustomDrawFooterCell(object sender, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e)        {            if (e.Column.SummaryItem.SummaryType == DevExpress.Data.SummaryItemType.Sum)            {                e.Info.DisplayText = Convert.ToString(e.Info.Value);// amount.ToString("¥0.0000");            }        }


运行代码就可以了;

 

原来的写法:

column.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;columns.SummaryItem.DisplayFormat = "{0:c4}";

显示效果不是很理想:

预期效果为:0.148 ==>  实际显示效果为:0.1500

0 0
原创粉丝点击