Results 1 to 6 of 6

Thread: [RESOLVED] remove Listview column sortorder

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2021
    Posts
    71

    Resolved [RESOLVED] remove Listview column sortorder

    I have a windows form with a Listview.
    When I click the header of the listview an arrow is shown to indicate the sorting order.


    Code:
        Private Sub ListView1_ColumnClick(sender As Object, e As ColumnClickEventArgs) Handles ListView1.ColumnClick
    
            Dim new_sorting_column As ColumnHeader =
            ListView1.Columns(e.Column)
    
            If e.Column = 0 Then
                Exit Sub
            End If
            Dim sort_order As System.Windows.Forms.SortOrder
            If m_SortingColumn Is Nothing Then
                sort_order = SortOrder.Ascending
            Else
                ' See if this is the same column.
                If new_sorting_column.Equals(m_SortingColumn) Then
                    If m_SortingColumn.Text.StartsWith(ChrW(&H25B2)) Then
                        sort_order = SortOrder.Descending
                    Else
                        sort_order = SortOrder.Ascending
                    End If
                Else
                    sort_order = SortOrder.Ascending
                End If
    
                ' Remove the old sort indicator.
                m_SortingColumn.Text =
                m_SortingColumn.Text.Substring(2)
            End If
    
            m_SortingColumn = new_sorting_column
            If sort_order = SortOrder.Ascending Then
                m_SortingColumn.Text = ChrW(&H25B2) & " " & m_SortingColumn.Text  'asc
            Else
                m_SortingColumn.Text = ChrW(&H25BC) & " " & m_SortingColumn.Text  'desc
            End If
    
            ListView1.ListViewItemSorter = New _
            ListViewComparer(e.Column, sort_order)
            ListView1.Sort()
        End Sub
    When I click a button the Listview is cleared. When that happens I want the arrow in the columnheader to be removed so it just shows the header title.
    Last edited by clausowitz; May 5th, 2021 at 02:51 PM.

Tags for this Thread

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