Ejemplo n.º 1
0
        private void OnColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
        {
            if (!sortable)
            {
                return;
            }

            LastSortedColumn = e.Column;
            RowSorterHelper rs = this.GetRowSorterHelper();

            if (rs == null)
            {
                this.ListViewItemSorter = new StringComparer(this);
            }
            else if (rs.Format == SortedListViewFormatType.String)
            {
                this.ListViewItemSorter = new StringComparer(this);
            }
            else if (rs.Format == SortedListViewFormatType.Numeric)
            {
                this.ListViewItemSorter = new NumericComparer(this);
            }
            else if (rs.Format == SortedListViewFormatType.Date)
            {
                this.ListViewItemSorter = new DateTimeComparer(this);
            }
            else if (rs.Format == SortedListViewFormatType.Custom)
            {
                if (this.CustomCompare != null)
                {
                    this.CustomCompare(this);
                    return;
                }
            }
            this.Sort();

            this.ListViewItemSorter = null;

            if (this.SortingOrder == SortOrder.Descending)
            {
                this.SortingOrder = SortOrder.Ascending;
            }
            else
            {
                this.SortingOrder = SortOrder.Descending;
            }
        }
Ejemplo n.º 2
0
 internal RowSorterHelper GetRowSorterHelper()
 {
     if (CompareFromSubClass == 1)
     {
         SortedListViewFormatType format = this.GetSortedFormatType(this.LastSortedColumn);
         return(new RowSorterHelper(this.LastSortedColumn, format));
     }
     for (int i = 0; i < rowSorterList.Count; i++)
     {
         RowSorterHelper rs = (RowSorterHelper)rowSorterList[i];
         if (rs != null && rs.ColumnIndex == LastSortedColumn)
         {
             return(rs);
         }
     }
     return(null);
 }