Page 1 of 1

Sort column

Posted: 31 Jan 2008, 15:51
by adhoc
Hello,
I am using TreeView Control Version 1.13.2 and I want to sort (by name, by size, by date ....) the list of the file of the ListView on clicking the column header.
Is it possible? How can I do that?

Thanks

Posted: 31 Jan 2008, 18:37
by TiKu
I'm not sure I understand your question right. You want to sort the items in the treeview by e. g. date, am I right?

Posted: 01 Feb 2008, 12:10
by adhoc
Yes.

Posted: 01 Feb 2008, 15:06
by TiKu
There's a property SortingCriteria. Set it to the index of the column by which you want to sort. This index must be the same as the index that the namespace's IShellFolder2/IShellDetails implementation uses for the column.
Here are some default column indexes:
  • 0 - Name
  • 1 - File size
  • 2 - File type
  • 3 - Last changed on
The whole thing is not that useful, because the property is for the whole treeview and in different namespaces the same column index may identify different columns, e. g. "My Computer" doesn't have a "File size" column and uses column index 1 for the "Drive type" column I think. Also some namespaces don't support sorting in this way.
Another way might be to send a TVM_SORTCHILDRENCB message to the treeview and do the sorting all by yourself. This gives you full control, but requires more work and some understanding of how the shell works internally.

HTH
TiKu