Sign in to follow this  
Followers 0
gcue

delete items from listview

4 posts in this topic

i am trying to cycle through a listview and see which items are checked for deletion

problem is, the item's index number changes so $x wouldnt be the same index number..

$startmenu_entries_count = _GUICtrlListView_GetItemCount($startmenu_entries_listview)

    For $x = 0 To $startmenu_entries_count
        $checked = _GUICtrlListView_GetItemChecked($startmenu_entries_listview, $x)

        If $checked = True Then
            _GUICtrlListView_DeleteItem($startmenu_entries_listview, $x)            
        EndIf
    Next

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

From my experience and messages from this board, deleting items from arrays while looping should be done backwards:

$startmenu_entries_count = _GUICtrlListView_GetItemCount($startmenu_entries_listview)

    For $x = $startmenu_entries_count to 0 step -1
        $checked = _GUICtrlListView_GetItemChecked($startmenu_entries_listview, $x)
        If $checked = True Then
            _GUICtrlListView_DeleteItem($startmenu_entries_listview, $x)            
        EndIf
    Next
Edited by PowerCat

Share this post


Link to post
Share on other sites

From my experience and messages from this board, deleting items from arrays while looping should be done backwards:

...

Well, that would have been my advice, too. :unsure:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

awesome =)

thanks fellas.

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