Objectlistview如何更改组头中的文本?

时间:2015-09-25 10:12:50

标签: c# listview sum objectlistview

我想更改群组标题的名称,但我无法在文档或Google上找到任何解决方案。

标题中的文字应该是在小组中总结的时间。

它应该是这样的:

enter image description here

1 个答案:

答案 0 :(得分:6)

  

标题中的文字应该是在小组中总结的时间。

没问题:)

olv.AboutToCreateGroups += delegate(object sender, CreateGroupsEventArgs args) {
    foreach (OLVGroup olvGroup in args.Groups) {
        int totalTime = 0;

        foreach (OLVListItem item in olvGroup.Items) {
            // change this block accordingly
             MyRowObjectType rowObject = item.RowObject as MyRowObjectType;
             totalTime += rowObject.MyNumericProperty;
            // change this block accordingly
        }

        olvGroup.Header += String.Format(" (Total time = {0})", totalTime);
    }
};
相关问题