Jump to content
Sign in to follow this  
MISIIM

ListView issues in Beta

Recommended Posts

MISIIM

After upgrading to the latest beta the function I used in a loop to select all items was removed. I tried both _GUICtrlListView_SetItemSelected and _GUICtrlListView_SetItemState. Both deselected any other items. Is there another way to select all items?

Func SelectAll()
    Local $index = -1;
    While True
        $index = _GUICtrlListView_GetNextItem($listView, $index, 0, 0);
        If $index == $LV_ERR Then ExitLoop;
        _GUICtrlListView_SetItemState($listView, $index, $LVIS_SELECTED, $LVIS_SELECTED);
    WEnd
EndFunc
Edited by MISIIM

Share this post


Link to post
Share on other sites
smashly

Hi, works for me .. eg:

#include<GuiConstants.au3>
#include<GuiListView.au3>

Global $State

GUICreate(":-)", 400, 300)
$listview = GUICtrlCreateListView ("col1   |col2|col3",10,10,380,250, $LVS_SHOWSELALWAYS)
For $i = 1 to 20
    GUICtrlCreateListViewItem("item" & $i & "|data" & $i & "|more" & $i,$listview)
Next
$button = GUICtrlCreateButton("Select All", 160, 270, 80, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            If Not $State Then
                For $i = 0 To _GUICtrlListView_GetItemCount($listview) -1
                    _GUICtrlListView_SetItemState($listView, $i, $LVIS_SELECTED, $LVIS_SELECTED)
                Next    
                GUICtrlSetData($button, "UnSelect All")
                GUICtrlSetState($listView, $GUI_FOCUS)
                $State = 1
            Else
                For $i = 0 To _GUICtrlListView_GetItemCount($listview) -1
                    _GUICtrlListView_SetItemState($listView, $i, 0, $LVIS_SELECTED)
                Next    
                GUICtrlSetData($button, "Select All")
                $State = 0
            EndIf   
    EndSwitch
WEnd
Done using Autoit v3.2.9.6 (beta)

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites
MISIIM

Ahhh! I accidentally reset the style parameter for GUICtrlCreateListView so only one could be selected. <_<

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  

×