Results 1 to 3 of 3

Thread: sorting in listview

  1. #1
    seljuk
    Guest

    sorting in listview

    How can sort a listview control according to its second or third item. (NOT first) for example [name] [number] [class] I want to sort the list using number or class variables. Is there anyone who can help me
    Visual basic has sortkey property does c# has any property like this. I find listviewitemsorter property but I didn't understand how can I use it.

  2. #2
    New Member
    Join Date
    Jan 2002
    Location
    Salt Lake City Utah
    Posts
    2
    Here's the way I do it, and it works well.

    ListView1.SortOrder = lvwAscending
    ListView1.Sorted = True
    ListView1.SortKey = 0 '1 = sort by column 1, 2 = sort by column 2, etc.

    This will sort the data by the SORTKEY value, where SORTKEY is the column number.

    You may want to turn off sorting after the list is sorted, though, since it does funny things with sorting turned on. Sort the data then turn it off.

    ListView1.Sorted = False

    If you want to sort the data by clicking a column header, place the following code in the ListView_ColumnClick Sub routine...

    ListView1.SortOrder = lvwAscending
    ListView1.Sorted = True
    ListView1.SortKey = ColumnHeader.Index - 1
    ListView1.Sorted = False 'Turn off sorting when done

  3. #3
    seljuk
    Guest

    Thumbs up thanks

    thanks for your your reply I will try it

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