listview的排序问题
写了如下的程序做listview的排序
Private Sub lstVDatalist_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
     Dim i As Integer
    
    With LstVDataList
        For i = 1 To .ColumnHeaders.count
            If i = ColumnHeader.Index Then
                .SortKey = i - 1            ''对指定的列进行排列
                .Sorted = True
                .SortOrder = lvwAscending
                .Refresh
            End If
        Next
    End With
End Sub但是点击一次后按升序排列,
请教 如何让它点击二次的时候按降序排,再点击的时候按照升序排!

解决方案 »

  1.   

    对这个属性操作不就行了?在点击二次时设置为降序排列
    .SortOrder = lvwDeAscending
      

  2.   

    If ListView1.SortOrder = lvwDescending Then
              ListView1.SortOrder = lvwAscending
         Else
              ListView1.SortOrder = lvwDescending
         End If
      

  3.   

    If .SortOrder = lvwDescending Then
                    .SortOrder = lvwAscending
                    Else: .SortOrder = lvwDescending
                    End If
      

  4.   

    Private Sub lstVDatalist_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
         Dim i As Integer
        
        With LstVDataList
            For i = 1 To .ColumnHeaders.count
                If i = ColumnHeader.Index Then
                    .SortKey = i - 1            ''对指定的列进行排列
                    .Sorted = True
                    .SortOrder = IIf(lvwDescending, lvwAscending, lvwDescending)
                    .Refresh
                End If
            Next
        End With
    End Sub
      

  5.   

    With Listview
    If .SortOrder = lvwDescending Then
         .SortOrder = lvwAscending
    Else
      .SortOrder = lvwDescending
    End If
    End With