Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...