Question

Sorry i think this might be duplicate question. I think so. Well i have done datagrid columns and it was able to sort with the code below but i tried to to this for lisview but it dosent seem to work. I want to sort list view based on a button click not column click. Is this even possible? I tried This link from MSDN but i didnt understand it. http://support.microsoft.com/kb/319399 So below here is my code for sorting datagridview. Is it posible to apply it for lisview? Integer i is a global variable.

     i += 1

    Dim x As Integer = grdDataGrid.CurrentCell.ColumnIndex

    If i Mod 2 = 1 Then
        'sort up
        grdDataGrid.Sort(grdDataGrid.Columns(x), System.ComponentModel.ListSortDirection.Ascending)

    ElseIf i Mod 2 = 0 Then
        'sort down
        grdDataGrid.Sort(grdDataGrid.Columns(x), System.ComponentModel.ListSortDirection.Descending)
Was it helpful?

Solution

Check the answer at the following post:

Sorting A ListView By Column

They give you several examples, but they also recommend ObjectListView who will make your job easier:

A Much Easier to Use ListView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top