ListView.Sort 方法

对列表视图的项进行排序。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Sub Sort
用法
Dim instance As ListView

instance.Sort
public void Sort ()
public:
void Sort ()
public void Sort ()
public function Sort ()

备注

通常情况下,使用 Sorting 属性基于项文本对项进行排序。若要自定义排序顺序,必须编写一个实现 IComparer 接口的类,并将 ListViewItemSorter 属性设置为该类的一个对象。例如,这在依据子项文本进行排序时很有用。有关以手动方式对项执行排序的更多信息,请参见 ListViewItemSorter 属性的示例。

如果 ListView.Sorting 属性设置为 SortOrder.None 以外的值,或者如果设置了 ListViewItemSorter 属性,则添加项时列表会自动排序。在标签文本发生更改时,项不会自动排序。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ListView 类
ListView 成员
System.Windows.Forms 命名空间
ListViewItemSorter