Jump to content

Treeview (checkbox) multiple choices


 Share

Recommended Posts

Hello all,

i have treeview checkbox style with multiple choices i am looking for the best way to retrieve the chekboxes selected function

thanks in advances.

$ClentL = GUICtrlCreateTreeView(32, 192, 225, 401, BitOr(256,55))
GUICtrlSetFont($ClentL, 8, 800, 0, "MS Sans Serif")
Link to comment
Share on other sites

Hi,

I am using the function _GUICtrlTreeView_GetChecked when testing even when check box is checked i still get result false

please advise

thx

For $x = 0 To UBound($StTreeArr) -1
     
     MsgBox(0,"test",$stat)
     $stat = _GUICtrlTreeView_GetChecked ($ClentL, $StTreeArr[$x])
    
    If $stat = True Then
         
MsgBox(4160, "Information", "Selection? " & _GUICtrlTreeView_GetText ($ClentL, $StTreeArr[$x]))
 EndIf
Next
Link to comment
Share on other sites

Quick example:

#include <GuiConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <GuiTreeView.au3>

$Style = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, _
               $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

$hGUI = GUICreate("Test GUI", 300, 200)

$TreeView = GUICtrlCreateTreeView(10, 10, 100, 180, $Style)

Global $aItems[11]
$aItems[0] = 10

For $i = 1 To $aItems[0]
    $aItems[$i] = GUICtrlCreateTreeViewItem("Item " & $i, $TreeView)
Next

$GetButton = GUICtrlCreateButton("Get selected", 200, 160, 80, 23)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GetButton
            MsgBox(0, "Selected Items:", _GetChecked())
    EndSwitch
WEnd

Func _GetChecked()
    Local $iSelected
    
    For $i = 1 To $aItems[0]
        If _GUICtrlTreeView_GetChecked($TreeView, GUICtrlGetHandle($aItems[$i])) Then $iSelected &= $aItems[$i] & @LF
    Next
    
    Return $iSelected
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...