CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2001
    Location
    india
    Posts
    50

    ListView sort only particular listitems(rows)

    I am working with a listview in vb6. If i want to sort the listitems i can set the sortorder and sort key,then if i set sorted = True,the listitems are sorted.
    My query is to know whether there is any way in which i can sort only a particular range of listitems or rows in a listview and not all of them.


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: ListView sort only particular listitems(rows)

    check out the LVM_SORTITEMS message in MSDN, it allows you to specific your own sorting callback function. I haven't tried it, but what I was think is this, say you got 20 items, and you only want to sort the first 10, then in the callback function, you only sort both items if they fall within the first 10, any thing more than that, just return a negative value (to indicate the second item should follow the first).

    Alternatively, you can gather the first 10 items into a normal array and sort it using a sorting function (if u need one, just get the code from http://vblib.virtualave.net in vbSorting), then place the item to the relevant position, cause you got the .Top & .Left property for every single item. which mean you are doing sorting & item placing manually.

    But, both are tedious.


    HTH

    cksiow
    http://vblib.virtualave.net - share our codes

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

Featured