PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: ListView Sorting  (Read 228 times)

Mark Strickland

  • Guest
ListView Sorting
« on: June 12, 2005, 09:05:12 PM »

Just to make sure I am not missing something I see two ways to sort a ListView control ---

1) Use column zero as your sort key.  Set the width to zero (although I know a user can readjust and see it).  When a user clicks on a column heading move the contents of that column to column zero for every row.  Of course the ascending or decending property must be set on the control.  My guess this would also create lots of display activity as you moved things around.

2) Unload the ListView data to an array and use ARRAY SORT in PB to do what ever you need then clear the ListView and reload it.  This obviously lets you have more flexibility.

If I am missing something EASY (sorry --- I forgot I was talking about Windows) let me know.

Thanks
Logged

Roger Garstang

  • Guest
ListView Sorting
« Reply #1 on: June 12, 2005, 10:31:45 PM »

Easiest way is using the array and ownerdata.  Then you just give it the array contents when it asks for it in the callback and you can sort or do whatever you want to the array on column clicks, etc.

You could also probably use an alternate approach like your other method, but not hiding the column.  You'd need to turn off auto sorting and swap column 0 for the sort column then sort the listview when finished swapping.
Logged