Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply a default sort column in ObjectListView

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.

like image 824
mroshaw Avatar asked Nov 05 '14 13:11

mroshaw


1 Answers

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?

like image 169
Rev Avatar answered Sep 28 '22 01:09

Rev