Results 1 to 3 of 3

Thread: sort by different columns

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    How do I get a listview in report view to sort in ascending or descending order by the column that is clicked. I tried:
    Code:
    Private Sub Listview_ColumnClick() 
    With Listview
    If (.SortOrder = lvwAscending) Then
        .SortOrder = lvwDescending
    Elseif (.SortOrder = lvwDescending) Then
        .SortOrder = lvwAscending
    Endif
    End With
    End Sub
    but that sorts by the first column no matter which column you click on. Do I have to rearrange the column indexes whenever a column is clicked or what?

  2. #2

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    anybody?

  3. #3
    Guest
    Try this:

    Code:
    'Author: Cierra Computers & Consulting
    'Origin: http://www.planet-source-code.com
    'Purpose: ListView Column Sort Function 
    'Version: VB5+ 
    
    Public Sub SortListView(ctlListView As ListView, intColulunHeaderIndex As Integer)
        ctlListView.Sorted = True
        ctlListView.SortKey = intColulunHeaderIndex - 1
    
    
        If ctlListView.SortOrder = lvwAscending Then
            ctlListView.SortOrder = lvwDescending
        Else
            ctlListView.SortOrder = lvwAscending
        End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width