locked
How to sort multiple listview on a form RRS feed

  • Question

  • I have several listview's on a form and would like to add this event to each listview to allow sorting:

    What changes are need to make this a common event?

     

    Thanks in advance

     private void lstFG_ColumnClick(object sender, ColumnClickEventArgs e)
        {
          // Determine if clicked column is already the column that is being sorted.
          if (e.Column == lvwColumnSorter.SortColumn)
          {
            // Reverse the current sort direction for this column.
            if (lvwColumnSorter.Order == SortOrder.Ascending)
            {
              lvwColumnSorter.Order = SortOrder.Descending;
            }
            else
            {
              lvwColumnSorter.Order = SortOrder.Ascending;
            }
          }
          else
          {
            // Set the column number that is to be sorted; default to ascending.
            lvwColumnSorter.SortColumn = e.Column;
            lvwColumnSorter.Order = SortOrder.Ascending;
          }
    
          // Perform the sort with these new sort options.
          this.lstFG .Sort();
    					
        }
    

    Wednesday, December 22, 2010 4:15 PM

Answers

All replies