文件名称:VB.NET ListView排序类
文件大小:2KB
文件格式:VB
更新时间:2016-03-27 10:59:49
排序 Listview VB.NET
一个用来排序ListView的类 以下需要在Listview的标题单击事件中加入 Private m_SortingColumn As ColumnHeader Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick Dim new_sorting_column As ColumnHeader = sender.Columns(e.Column) Dim sort_order As System.Windows.Forms.SortOrder If m_SortingColumn Is Nothing Then sort_order = SortOrder.Ascending Else If new_sorting_column.Equals(m_SortingColumn) Then If m_SortingColumn.Text.EndsWith(" △") Then sort_order = SortOrder.Descending Else sort_order = SortOrder.Ascending End If Else sort_order = SortOrder.Ascending End If m_SortingColumn.Text = m_SortingColumn.Text.Substring(0, m_SortingColumn.Text.Length - 3) End If m_SortingColumn = new_sorting_column '重新显示列标题 If sort_order = SortOrder.Ascending Then m_SortingColumn.Text &= " △" Else m_SortingColumn.Text &= " ▽" End If sender.ListViewItemSorter = New ClsListViewSorter(e.Column, sort_order) sender.Sort() sender.ListViewItemSorter = Nothing End Sub