Results 1 to 4 of 4

Thread: problem with sorting a listview

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    problem with sorting a listview

    Umm, how can I sort a specified column of a listview control? I'm using a listView with the View set to "Details". I want it to be so that when the user clicks on each column, that column would be sorted. sounds like I can only sort the first column. How can I sort the other columns?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    You need to look at ListViewItemSorter. He is a good post to get you going.
    http://www.vbcity.com/forums/topic.asp?tid=2901
    Wind and waves resolves all problems.

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Thumbs up

    ok tnx alot it works
    for anyone who doesnt want to dig through their stuff, here's how to do it:

    VB Code:
    1. Private Class SortOrder
    2. Implements IComparer
    3.   Dim Column As Integer
    4.   Public Sub New(ByVal aColumn As Integer)
    5.   Column = aColumn
    6.   End Sub
    7.  
    8.   Public Function compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
    9.   Dim xItem As System.Windows.Forms.ListViewItem = x
    10.   Dim yItem As System.Windows.Forms.ListViewItem = y
    11.   Return (xItem.SubItems(Column).Text).CompareTo(yItem.SubItems(Column).Text)
    12.   End Function
    13. End Class

    anyways I have no clue whatsoever how it works
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    umm just another question if anyone can help: when option Strict is On, it will give me error from these two:

    VB Code:
    1. Dim xItem As System.Windows.Forms.ListViewItem = x
    2. Dim yItem As System.Windows.Forms.ListViewItem = y
    it 's because it's converting from object to ListViewItem. What should I do if I want to keep Option Strict on?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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