Jump to content
Sign in to follow this  

Listview _GUICtrlListView_GetItemChecked loop

Recommended Posts


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)
            $count += 1
            ConsoleWrite($totsel&" - "&$x&" "&$totsel2&@CRLF)

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

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

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