[section_title title=Introduction]

Once again, I have found a missing piece on the internet. You can find numerous articles online that show you how to sort items in a ListView using C# but unfortunately none of these show how to actually indicate which column the list is currently sorted on. This is normally done by showing an arrow icon column header which points up or down based on the sorting criteria.

A Windows Vista ListView showing the sort icon

Windows Presentation Framework, part of the .NET 3.0 framework, comes with support for adding the sorting icons without dealing with Windows API (a.k.a. Win32 API) but .NET 2.0 and prior versions don’t. Most of the basic ListView introductions don’t talk about adding these icons mainly because of this one reason, you have to at least understand Win32 API. If you search the internet you will find that most of the reference to adding these icons are in forums or other such discussion boards. So, my goal is to save everyone some trouble and explain how this is done.