Esempio n. 1
0
        /// <summary>
        /// Allow sorting of list view columns
        /// </summary>
        /// <param name="sender">System parm</param>
        /// <param name="e">System parm</param>
        /// <history>
        /// [Curtis_Beard]	   02/06/2005	Created
        /// [Curtis_Beard]	   07/07/2006	CHG: add support for count column sorting
        /// [Curtis_Beard]	   10/06/2006	FIX: clear sort indicator propertly
        /// [Curtis_Beard]		02/17/2012	CHG: update listview sorting
        /// </history>
        private void lstFileNames_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            int clearColIndex = -1;

             // set to wait cursor
             lstFileNames.Cursor = Cursors.WaitCursor;

             // Determine whether the column is the same as the last column clicked.
             if (e.Column != __SortColumn)
             {
            // Remove sort indicator
            if (__SortColumn != -1)
            {
               clearColIndex = __SortColumn;
            }

            // Set the sort column to the new column.
            __SortColumn = e.Column;

            // Set the sort order to ascending by default.
            if (e.Column == Constants.COLUMN_INDEX_COUNT ||
               e.Column == Constants.COLUMN_INDEX_SIZE ||
               e.Column == Constants.COLUMN_INDEX_DATE)
            {
               lstFileNames.Sorting = SortOrder.Descending;
            }
            else
            {
               lstFileNames.Sorting = SortOrder.Ascending;
            }
             }
             else
             {
            // Determine what the last sort order was and change it.
            if (lstFileNames.Sorting == SortOrder.Ascending)
               lstFileNames.Sorting = SortOrder.Descending;
            else
               lstFileNames.Sorting = SortOrder.Ascending;
             }

             // Set the ListViewItemSorter property to a new ListViewItemComparer object.
             ListViewItemComparer comparer = new ListViewItemComparer(e.Column, lstFileNames.Sorting);
             lstFileNames.ListViewItemSorter = comparer;

             // Call the sort method to manually sort.
             lstFileNames.Sort();

             // Display sort image and highlight sort column
             Windows.API.ListViewExtensions.SetSortIcon(lstFileNames, e.Column, lstFileNames.Sorting);

             // Apply theming since sorting removes it.
             Windows.API.ListViewExtensions.SetTheme(lstFileNames);

             // restore to default cursor
             lstFileNames.Cursor = Cursors.Default;
        }
Esempio n. 2
0
        /// <summary>
        /// Allow sorting of list view columns
        /// </summary>
        /// <param name="sender">System parm</param>
        /// <param name="e">System parm</param>
        /// <history>
        /// [Curtis_Beard]	   02/06/2005	Created
        /// [Curtis_Beard]	   07/07/2006	CHG: add support for count column sorting
        /// [Curtis_Beard]	   10/06/2006	FIX: clear sort indicator propertly
        /// </history>
        private void lstFileNames_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            // Determine whether the column is the same as the last column clicked.
             if (e.Column != __SortColumn)
             {
            // Remove sort indicator
            if (__SortColumn != -1)
               Windows.API.SetHeaderImage(lstFileNames, __SortColumn, SortOrder.Ascending, false);

            // Set the sort column to the new column.
            __SortColumn = e.Column;

            // Set the sort order to ascending by default.
            lstFileNames.Sorting = SortOrder.Ascending;
             }
             else
             {
            // Determine what the last sort order was and change it.
            if (lstFileNames.Sorting == SortOrder.Ascending)
               lstFileNames.Sorting = SortOrder.Descending;
            else
               lstFileNames.Sorting = SortOrder.Ascending;
             }

             // set column sort image
             Windows.API.SetHeaderImage(lstFileNames, e.Column, lstFileNames.Sorting, true);

             // Set the ListViewItemSorter property to a new ListViewItemComparer object.
             ListViewItemComparer comparer;

             // set comparer for integer types if the count column, otherwise try date/string
             if (e.Column == Constants.COLUMN_INDEX_COUNT)
            comparer = new ListViewItemComparer(e.Column, lstFileNames.Sorting, true);
             else
            comparer = new ListViewItemComparer(e.Column, lstFileNames.Sorting);

             lstFileNames.ListViewItemSorter = comparer;

             // Call the sort method to manually sort.
             lstFileNames.Sort();
        }