2015-09-25 15 views

回答

5

頭中的文字應該是被該組中總結出了時間。

沒問題:)

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); 
    } 
}; 
+0

1.什麼是委託,我應該在哪裏寫代碼了嗎?因爲我發現事件「Abouttocreategroups」,但它實際上不在那裏工作 2.什麼是MyRowObjectType? (我應該使用哪個)? – Cortana

+1

'AboutToCreateGroups'是一個ObjectListView事件,並在顯示組之前調用。因此,您實際上可以對那些將直接反映在OLV上的組進行更改。 MyRowObjectType只是您用於填充OLV的基礎對象類型的佔位符。訪問它的'Zeit'屬性添加它們。 –

相關問題