Jump to content
Sign in to follow this  
Stalker0

Help with ListView Sorting

Recommended Posts

Stalker0

I'm trying to use _GUICtrlListViewSort to do some sorting, but I don't understand the second attribute of the function.

The second attribute requires $b_descending. I've tried putting in true or false for this, but the list doesn't seem to be sorting. Am I using the wrong attribute, do I need to do some kind of listview refresh to see the sorted results, etc.

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

it is in the helpfile. E.g. try putting the number of colums in there.

Dim $B_DESCENDING[3] ; 3 colums.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Stalker0

Hi,

it is in the helpfile. E.g. try putting the number of colums in there.

Dim $B_DESCENDING[3] ; 3 colums.

So long,

Mega

Its a 1 collumn listview. I used this command:

$b_descending = 0

_GuiCtrlListViewSort($final, $b_descending, 1)

Which does do the sort. However, the problem now is it only sorts it once.

For example, if I have a list 1-5, and add 1, 3, and 5 to the list it looks like this.

1

3

5

However, if I add 2, it now looks like this:

1

3

5

2

Share this post


Link to post
Share on other sites
Stalker0

I finally said screw it I'll do it the long way. I just put all of the listview into an array, sorted it, and set it back.

Here's the code if anyone wants it:

Func SortList($final)
    $count = _GUICtrlListViewGetItemCount($final)
    If $count > 0 THEN
        Local $array[1]
        For $i = 0 to $count -1
            $text = _GUICtrlListViewGetItemText($final, $i)
            _ArrayAdd($array, $text)
        Next
        _GUICtrlListViewDeleteAllItems($final)
        _ArraySort($array, 0)
        For $i = 1 to $count
            GuiCtrlCreateListViewItem($array[$i], $final)
        Next
        
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.