Jump to content
Sign in to follow this  


Recommended Posts


So I'm trying to use the _GuiCtrlListView_SetItemSelected() UDF to either select all or none of the items in my listview, but it doesn't seem to do anything. Does anyone see anything wrong with my example script below?

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

Global $All
Global $None
Global $nMsg


Func _Main()

    Local $GUI, $hListView
    $GUI = GUICreate("(External) ListView Create", 400, 330)

    $hListView = _GUICtrlListView_Create ($GUI, "", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle ($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    ; Add columns
    _GUICtrlListView_InsertColumn ($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn ($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn ($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem ($hListView, "Row 1: Col 1")
    _GUICtrlListView_AddSubItem ($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem ($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem ($hListView, "Row 2: Col 1")
    _GUICtrlListView_AddSubItem ($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem ($hListView, "Row 3: Col 1", 2)

    $All = GUICtrlCreateButton ("All", 200, 278, 50, 30)
    $None = GUICtrlCreateButton ("None", 270, 278, 50, 30)

    While 1     
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $All
                _GUICtrlListView_SetItemSelected ($hListview, -1, 1)

            Case $None
                _GUICtrlListView_SetItemSelected ($hListview, -1, 0)
            Case $GUI_EVENT_CLOSE
                GUIDelete ()
EndFunc   ;==>_Main

Share this post

Link to post
Share on other sites

$hListView = _GUICtrlListView_Create ($GUI, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
You're my hero Gary!

The example in the help file for _GuiCtrlListView_SetItemSelected() doesn't create the listview control using the UDF, _GuiCtrlListView_Create (and thus the way you gave above), so even though the help file says you can set the index to -1 for the SetItemSelected() function, it doesn't work with the example because it creates the listview using GuiCtrlCreateListView() (which is what threw me off).

Would that be worth changing?

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