XtraGridView上的自定义SUM摘要

时间:2012-03-29 07:54:34

标签: c# gridview devexpress

我正在使用Devexpress 11.2

XtraGridView我希望在包含百分比数据的列上显示摘要SUM 在列上我有存储器spinEdit与掩码“p2” 所以,如果我的显示值为50%,则值为0.5

如果我有网格值

0.5 - 50%  
0.3 - 30%   
0.2 - 20%  

摘要SUM将为1,但我想显示100%
请你帮我 谢谢

2 个答案:

答案 0 :(得分:3)

将摘要的DisplayFormat属性设置为大写“P”。

请参阅this以供参考。

答案 1 :(得分:1)

添加自定义未绑定列。
http://documentation.devexpress.com/#WindowsForms/CustomDocument1477

然后在CustomUnboundColumnData

void gridView1_CustomUnboundColumnData(object sender,
DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) {
    if (e.Column.FieldName == "Percent" && e.IsGetData) {
        GridView view = (GridView)sender;
        DataRow row = view.GetDataRow(e.RowHandle); //If datasource = datatable
        //Use GetRow if custom business object and cast it.
        e.Value = Value*100 + "%"; //I am sure there is a better way.
    }
}

如果需要,您可以隐藏/删除'p2'列。

相关问题