-1

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)
shaik ibrahim
  • 187
  • 5
  • 10
  • 30

1 Answers1

-2

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

Community
  • 1
  • 1
Carlos Landeras
  • 10,594
  • 11
  • 51
  • 81