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 Nov. 11, 2008 (about 1 year, 2 months after publishing)
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 Nov. 22, 2008 (about 1 year, 2 months after publishing)
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 Nov. 22, 2008 (about 1 year, 2 months after publishing)
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 Jun. 26, 2010 (about 2 years, 9 months after publishing)
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 Jun. 26, 2010 (about 2 years, 9 months after publishing)
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 Nov. 22, 2008 (about 1 year, 2 months after publishing)
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 Apr. 23, 2009 (about 1 year, 7 months after publishing)
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 Apr. 28, 2009 (about 1 year, 7 months after publishing)
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.
9:29 a.m. Tuesday Oct. 4, 2011 (about 4 years after publishing)
how to place the sort icon to the right corner of the column santhosh
Can u tell me how to move the sort icon to the border of the column... The code is working fine...

Thanks a lot Bro.....
2:53 p.m. Monday Oct. 10, 2011 (about 4 years after publishing)
Excellent - a really a nice feature Mr. Brandt
Thank you for the contribution. I would never have solved it if I hadn't stubled upon it here!
Add new comment