Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15661

VS 2019 [RESOLVED] remove Listview column sortorder

$
0
0
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.

Viewing all articles
Browse latest Browse all 15661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>