ITEEDU

更改显示列表方式

大图标显示

  this.listView1.View=View.LargeIcon;

小图标显示

  this.listView1.View=View.SmallIcon;

详细显示

  this.listView1.View=View.Details;

按列表排序

ListViewItemComparer sorter = new ListViewItemComparer(e.Column);
listView1.ListViewItemSorter = sorter;
listView1.Sort();

关键是做一个排序类ListViewItemComparer。

public class ListViewItemComparer : IComparer
{
    public ListViewItemComparer(int columnIndex)
    {
        Column = columnIndex;
    }

    public int Compare(object x, object y)
    {

        ListViewItem listX = (ListViewItem)x;
        ListViewItem listY = (ListViewItem)y;
		...
        return String.Compare(listXText, listYText);
    }
}