Relax
Relax

Reputation: 283

How to group objects in ObjectListView?

I'm having problems with grouping my objects in an ObjectListView.

I've already looked for some examples on Google but nothing fit or worked for me.

For each different value in a special column I want to add a group and put all objects with the same value into this group.

I want to group by the driver of a car:

this.AenderungenFOLV.ShowGroups = true;
this.olvColumn1.GroupKeyGetter = delegate(object rowObject)
        {
            Fahrzeug fahrzeug = (Fahrzeug)rowObject;
            return fahrzeug.Fahrer;
        };

Upvotes: 2

Views: 5973

Answers (1)

Rev
Rev

Reputation: 6122

There are several things that come to my mind

By default the grouping is performed on the primary column or the last sort column (if it has been sorted). You may have to either

  • explicitly build the groups olv.BuildGroups(groupColumn, sortOrder);
  • set a default sort column olv.AlwaysGroupByColumn = groupColumn;
  • call olv.Sort(groupColumn); to implicitly trigger grouping

One of the above should suffice.

Upvotes: 4

Related Questions