ListView.Sort Method


对列表视图的项进行排序。Sorts the items of the list view.

 void Sort();
public void Sort ();
member this.Sort : unit -> unit
Public Sub Sort ()


通常使用 Sorting 属性对项进行排序,该属性基于项文本对项进行排序。Typically items are sorted using the Sorting property, which sorts items based on the item text. 若要自定义排序顺序,必须编写一个类来实现 IComparer 接口,并将 ListViewItemSorter 属性设置为该类的对象。To customize the sort order, you must write a class that implements the IComparer interface and set the ListViewItemSorter property to an object of that class. 例如,当你想要按子项文本对项进行排序时,这会很有用。This is useful, for example, when you want to sort items by subitem text. 有关对项执行手动排序的详细信息,请参阅 ListViewItemSorter 属性的示例。For more information on performing manual sorting of items, see the example for the ListViewItemSorter property.

如果 ListView.Sorting 属性设置为 SortOrder.None 以外的值,或者如果设置了 ListViewItemSorter 属性,则添加项时,将自动对该列表进行排序。If the ListView.Sorting property is set to a value other than SortOrder.None or if the ListViewItemSorter property is set, the list is sorted automatically when items are added. 标签文本更改时,不会自动对项目进行排序。Items are not sorted automatically when the label text changes.

Applies to

See also