我有一个 winforms 应用程序(C#、.NET 3.5,但最终迁移到 4.0),它使用 ListView 以与 Windows 资源管理器类似的样式呈现附件(文件/Web 链接)。
此功能已受到应用程序用户的好评。已向 edxpand 发出请求,以包括通过单击列标题对详细信息视图进行排序(与 Windows 资源管理器中相同)
这是我的目标排序风格(使用三角形字形指示排序方向)
通过使用列 ImageKey 属性,我已经接近实现这一目标。
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";
}
}
不幸的是,图像出现在文本的左侧,而不是右侧。
ColumnHeader TextAlign 属性设置为 Left,设计器中可用的其他属性很少,似乎没有任何用处。
有谁知道在左对齐时是否可以使图像出现在文本的右侧,或者我将不得不使用另一种方法?
我遇到的一个选项是在标题文本中使用 unicode 字形。但是,如果可能,我宁愿避免这种情况,因为 unicode 字形不是特别好。