Sign in to follow this  
Followers 0
rootx

Listview _GUICtrlListView_GetItemChecked loop

2 posts in this topic

#1 ·  Posted (edited)

I need help to fix this

Func deletesel($totsel)
    $count = 0
    For $x = 0 To $totsel
        If _GUICtrlListView_GetItemChecked($listview, $x) Then
            $totsel2 = _GUICtrlListView_GetItemText($ListView,$x, 6)
            _GUICtrlListView_DeleteItem($ListView,$x)
            _GUICtrlListView_SetItemChecked($listview,$x,False)
            $count += 1
            ConsoleWrite($totsel&" - "&$x&" "&$totsel2&@CRLF)
        EndIf
    Next

    $TOT2 = _GUICtrlListView_GetItemCount($ListView)
    ConsoleWrite($TOT2&"  "&$count)
    Return $count
EndFunc

1. the first row have index = 0 .... if you try to count it fails... EX 10-0=10, Obviously if you select more elements from the second row, the result is correct.

2. I have added _GUICtrlListView_SetItemChecked($listview,$x,False) because at the end of the loop the first elements result checked.

Edited by rootx

Share this post


Link to post
Share on other sites



#2 ·  Posted

Just a guess but if you are deleting the listview items, I would think you'd have to work backwards to delete them to keep the indexes the same. If you delete the item where x = 1 for example then when you set the item as checked it will be a different item at index one.

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  
Followers 0