Reputation: 335
This seems like a really stupid question, but I can't work it out! How do I programmatically apply a sort order to an ObjectListView? My code is very straight forward:
listOfItems.Add(new ListItem(a, b, c, d));
listOfItems.Add(new ListItem(e, f, g, h));
objectListView.SetObjects(listOfItems);
But it's at this point I want to enforce sorting on, say, "column 3 ascending" and I cannot for the life of me find a way to do it!
I don't want to do anything fancy, just programmatically simulate the effect of the user clicking the column 3 header until it's sorted ascending.
Upvotes: 5
Views: 4269
Reputation: 6092
Its pretty straightforward, maybe you just missed it:
objectListView1.Sort(targetColumn, SortOrder.Ascending);
This would use the default sorting or the CustomSorter (if implemented) for the specified column.
Is this what you want to achieve?
Upvotes: 11