Click to See Complete Forum and Search --> : ListView sort only particular listitems(rows)


sravanthi
June 21st, 2001, 12:32 AM
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.

cksiow
June 21st, 2001, 08:05 PM
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