Quote:
>Yep, Isn't that a complete pain in the ass!!!
>There are two approaches neither pretty.
>One involves a Callback which implements a custom Compare routine (I am not
>going there!).
>The other involves creating a Dummy column, populating it with a"0" padded
>version of your
>data (so it will sort correctly), Sort on that Dummy Column and then Remove
>the Column!
>SUCKS! DOESN'T IT!!! Any M$ folks{*filter*} out? Consider that my suggestion
>for Ver 7.
>Neila
The problem with (1) is that the listitems collection become out of synch
with the actual listview. At that point you are better off rewriting the
whole COM listview object yourself in VB around an API-created listview.
To do that right would take a good developer a LONGGGG time, probably
months.
The problem with (2) is that you are (a) modifying the column data and
(b) it won't work right with many date formats regardless of padding.
On a current client's project, I opted to go with (c), a custom ActiveX
control wrapping the listview which stores data objects implementing
several custom interfaces. One of the interfaces supports sorting by
data stored in variants. Hence, instead of trying to sort strings in
listview, you instead sort collections of data/business objects by their
values, whether dates, strings, longs, etc. The downside is you have to
clear out the listview, sort the data objects, repopulate the listview,
and go on as if no magic had happened. Fortunately, VB can write pretty
fast sorts, so reasonable listviews can sorted in a fraction of a second.
Matthew Cromer
President, SDA Consulting, Inc.
http://www.*-*-*.com/