2015-09-25 12 views

risposta

5

il testo nell'intestazione dovrebbe essere un momento che si riassume nel gruppo.

Nessun problema :)

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. ciò che è delegato e dove avrei dovuto scrivere questo codice in basso? perchè ho trovato l'evento "Abouttocreategroups" ma in realtà non funziona lì 2. E che cos'è MyRowObjectType? (quale uso dovrei usare)? – Cortana

+1

'AboutToCreateGroups' è un evento ObjectListView e viene chiamato prima che i gruppi vengano visualizzati. In questo modo puoi apportare modifiche ai gruppi che rifletteranno direttamente sull'OLV. MyRowObjectType era solo un segnaposto per il tipo di oggetto sottostante che si utilizza per popolare OLV. Accedi alla sua proprietà 'Zeit' lì aggiungere aggiungili. –