I have a winforms application (C#, .NET 3.5 but eventually migrating to 4.0) which uses a ListView to present attachments (files/web links) in a similar style to windows explorer.
This functionality has been well received by he application users. A request has been made to edxpand this to include sorting the details view by clicking on column headers (same as in windows explorer)
This is the style of sorting that I'm aiming for (using a triangular glyph to indicate sort direction)
I've come close to achieving this by using the columns ImageKey property.
if (lvAttachments.ListViewItemSorter != null)
{
lvAttachments.Sort();
if (lvwColumnSorter != null)
{
if (lvwColumnSorter.Order == System.Windows.Forms.SortOrder.Ascending)
lvAttachments.Columns[lvwColumnSorter.SortColumn].ImageKey = "sortAsc";
if (lvwColumnSorter.Order == System.Windows.Forms.SortOrder.Descending)
lvAttachments.Columns[lvwColumnSorter.SortColumn].ImageKey = "sortDesc";
}
}
Unfortunately the image appears to the left of the text, rather than the right.
ColumnHeader TextAlign property is set to Left, there are few other properties available in the designer, none appear to be of any use.
Does anyone know if it's possible to make the image appear to the right of the text while it is left aligned, or is there another approach I will have to use?
One option I've come across is using a unicode glyph in the header text. However, I'd rather avoid this if possible as the unicode glyph does not particularly nice.