Conclusion

Published Tuesday September 11, 2007

There you have it. If you are not familiar with sorting ListView in general then I suggest that you check out the following links.

If you have any questions or comments you can always click on the “contact me” link in the top part of this website to follow-up.

-- End --
Previous: Sample & Demo  

Comments

6:26 p.m. Tuesday November 11, 2008 (about 1 year, 2 months later)
Where's the icon? John Moreno
I've got the code compiling and running (apparently), but no icon ever appears in the column header, and of course it doesn't change...it doesn't seem to do anything.

Does this work using the headers imagelist? Any idea as to what I'm doing wrong?
6:03 p.m. Saturday November 22, 2008 (about 1 year, 2 months later)
Sorry, my mistake John Moreno
Sorry, I was trying to do it in VB with an existing project and as I said it just wasn't working. I created a new project, and there its working. Not sure what I was doing wrong with the existing project, but I'l get it.
6:35 p.m. Saturday November 22, 2008 (about 1 year, 2 months later)
RE: Sorry, my mistake farhan
Hi John,

My guess would be that a constant wasn't being referenced correctly.

Good luck,
Farhan
2:20 p.m. Saturday June 26, 2010 (about 2 years, 9 months later)
RE: Sorry, my mistake John Moreno
I finally figured out why it was working with a new project and not with the old one, I didn't have XP visual styles enabled (was going to add it to another existing project, which also didn't have XP styles enabled).
3:36 p.m. Saturday June 26, 2010 (about 2 years, 9 months later)
RE: RE: Sorry, my mistake farhan
I am glad that you figured it out. It is a little weird that visual styles are required for this functionality.

Have a great weekend!
Farhan
6:51 p.m. Saturday November 22, 2008 (about 1 year, 2 months later)
Sorry, my mistake John Moreno
Nope -- I was setting the icons and then setting the listview's Sorting property. Moving the SetSortIcon call to immediately precede the Refresh fixed the problem.

Would you like the VB solution? Other than being in another lanague, it also has a couple of extremely minor improvements (a bug fix with previouslySortedColumn/previouslySortedColumn and using Delegates to give reasonable names to the SendMessage calls).
1:39 a.m. Thursday April 23, 2009 (about 1 year, 7 months later)
What about column header text? gewe
Nice, but using this code removes the column header text, only leaving the sort indicator. How can I get the sort indicator AND the text?
9:11 a.m. Tuesday April 28, 2009 (about 1 year, 7 months later)
RE: What about column header text? farhan
@gewe Make sure hdItem.fmt has HDF_STRING and either HDF_SORTUP or HDF_SORTDOWN. That should allow you to display both the text and the sort icon.
Add new comment