public FrmQryBar() { InitializeComponent(); lvwColumnSorter = new ListViewSorter(); this.listData.ListViewItemSorter = lvwColumnSorter; FConst.SetColor(this); }
//listView排序 public static void OrderListView(ListView lv, ColumnClickEventArgs e, ListViewSorter lvwColumnSorter) { lv.BeginUpdate(); lvwColumnSorter.nSortTag = Convert.ToInt32(lv.Columns[e.Column].Tag); if (e.Column == lvwColumnSorter.SortColumn) { // 重新设置此列的排序方法. if (lvwColumnSorter.Order == SortOrder.Ascending) { lvwColumnSorter.Order = SortOrder.Descending; } else { lvwColumnSorter.Order = SortOrder.Ascending; } } else { // 设置排序列,默认为正向排序 lvwColumnSorter.SortColumn = e.Column; lvwColumnSorter.Order = SortOrder.Ascending; } lv.Sort(); lv.EndUpdate(); }