Sign in to follow this  
Followers 0
lrstndm

Treeview Get Checked not updating?

3 posts in this topic

#1 ·  Posted (edited)

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

Local $checked
Local $array[4]
$array[1] = "Test 1"
$array[2] = "Test 2"
$array[3] = "Test 3"

Opt("GUIOnEventMode", 1)
$form = GUICreate("Checked", 602, 432, 192, 124)
$treeview = GUICtrlCreateTreeView(35, 200, 184, 80, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_CHECKBOXES) + BitNOT($TVS_HASLINES), $WS_EX_CLIENTEDGE)
For $t = 1 To UBound($array) -1 Step + 1
GUICtrlCreateTreeViewItem($array[$t], $treeview)
Next
$button = GUICtrlCreateButton("CHECK", 5,5,100,50)
GUICtrlSetOnEvent($button, "Go")
GUISetState(@SW_SHOW, $form)
While 1
Sleep(10)

WEnd

Func Go()
$count = _GUICtrlTreeView_GetCount($treeview)
For $x = 1 To $count Step + 1
$checked = _GUICtrlTreeView_GetChecked($treeview, $array[$x]) ; $checked is set to True if item is checked and to False if item is not checked
MsgBox(0, '', $array[$x] &amp; " checked is: " &amp; $checked)
Next
EndFunc

Why isn't my code working?

I want the variable '$checked' to be updated but as I see it is not doing that.

What am I doing wrong?

Edited by lrstndm

Share this post


Link to post
Share on other sites



You haven't saved the Handle of the TreeView items and are querying the status with the value.

Untested:

Local $checked
Local $Array[4]
Local $hArray[4]
$Array[1] = "Test 1"
$Array[2] = "Test 2"
$Array[3] = "Test 3"

Opt("GUIOnEventMode", 1)
$form = GUICreate("Checked", 602, 432, 192, 124)
$treeview = GUICtrlCreateTreeView(35, 200, 184, 80, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES) + BitNOT($TVS_HASLINES), $WS_EX_CLIENTEDGE)
For $t = 1 To UBound($Array) - 1 Step +1
    $hArray[$x] = GUICtrlCreateTreeViewItem($Array[$t], $treeview)
Next
$button = GUICtrlCreateButton("CHECK", 5, 5, 100, 50)
GUICtrlSetOnEvent($button, "Go")
GUISetState(@SW_SHOW, $form)
While 1
    Sleep(10)

WEnd

Func Go()
    $count = _GUICtrlTreeView_GetCount($treeview)
    For $x = 1 To $count Step +1
        $checked = _GUICtrlTreeView_GetChecked($treeview, $hArray[$x]) ; $checked is set to True if item is checked and to False if item is not checked
        MsgBox(0, '', $Array[$x] & " checked is: " & $checked)
    Next
EndFunc   ;==>Go

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks a lot :)

little bit changes to your code, but then it works.

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