Jump to content

TreeView read text


Go to solution Solved by Melba23,

Recommended Posts

  • Moderators

kamel,

Welcome to the AutoIt forum. :)

Loop through the arrays using _GUICtrlTreeView_GetChecked to find out if the items are checked. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

kamel,

Welcome to the AutoIt forum. :)

Loop through the arrays using _GUICtrlTreeView_GetChecked to find out if the items are checked. ;)

M23

Thanks for the reply

Already used the function

if _GUICtrlTreeView_GetChecked ($TreeView1,$_child[$I]) = True then

but how Print all item like

test -0 , Child19 , etc21

test - 2 , Child1 , etc16

Link to post
Share on other sites
  • Moderators

kamel,

Post the code you have tried (see here how to do it) and then we can see what to change. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

:sweating:

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Global $name[50]
Global $_child[50]
Global $_child2[50]
 Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView", 400, 300)
    $Button1 = GUICtrlCreateButton("1",96, 273, 56, 25, 25)
    $TreeView1 = GUICtrlCreateTreeView(2, 2, 388, 268, $iStyle, $WS_EX_CLIENTEDGE)

    GUISetState()


for $i = 0 to 5
    $name[$I]= GuiCtrlCreateTreeViewItem("name" & $i , $TreeView1)
Next


For $e = 0 to 5
 $_child[$e]= GuiCtrlCreateTreeViewItem("Child" & Random(11,22,1) , $name[$e])
Next


For $e = 0 to Random(1,9,1)
 $_child2[$e]= GuiCtrlCreateTreeViewItem("etc" & Random(11,22,1) , $_child[$e])
Next
_GUICtrlTreeView_Expand($TreeView1)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1


for $x =0 to _GUICtrlTreeView_GetCount($TreeView1)
;    IF _GUICtrlTreeView_GetChildren($TreeView1,$name[$x]) = True then
        FOR $I =0 TO _GUICtrlTreeView_GetChildCount($TreeView1,$name[$x])
            if _GUICtrlTreeView_GetChecked ($TreeView1,$_child2[$I]) = True then
                $nameX =    _GUICtrlTreeView_GetText($TreeView1, $name[$x])
                $Cild =    _GUICtrlTreeView_GetText($TreeView1, $_child[$I])
                $Cild2 =    _GUICtrlTreeView_GetText($TreeView1, $_child2[$I])
                ConsoleWrite($nameX&"<-"&$Cild&"<-"&$Cild2 & @CRLF)
            EndIf
        Next
    ;EndIf
Next
    EndSwitch
WEnd
Link to post
Share on other sites
  • Moderators
  • Solution

kamel,

I would do something like this: ;)

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

Global $name[50], $_child[50], $_child2[50]
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

GUICreate("TreeView", 400, 300)

$Button1 = GUICtrlCreateButton("1", 96, 273, 56, 25, 25)
$TreeView1 = GUICtrlCreateTreeView(2, 2, 388, 268, $iStyle, $WS_EX_CLIENTEDGE)

GUISetState()

$cStart = GUICtrlCreateDummy() ; This marks the start of the treeview items <<<<<<<<<<<<<<<<
For $i = 0 To 5
    $name[$i] = GUICtrlCreateTreeViewItem("name" & $i, $TreeView1)
Next

For $e = 0 To 5
    $_child[$e] = GUICtrlCreateTreeViewItem("Child" & Random(11, 22, 1), $name[$e])
Next

For $e = 0 To Random(1, 9, 1)
    $_child2[$e] = GUICtrlCreateTreeViewItem("etc" & Random(11, 22, 1), $_child[$e])
Next
$cEnd = GUICtrlCreateDummy() ; And this the end <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

_GUICtrlTreeView_Expand($TreeView1)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ; Run through all the items
            For $cItem = $cStart + 1 To $cEnd - 1
                ; We need the handle of the item
                $hHandle = GUICtrlGetHandle($cItem)
                ; is it checked?
                If _GUICtrlTreeView_GetChecked($TreeView1, $hHandle) = True Then
                    ; Get the full tree
                    $sTree = _GUICtrlTreeView_GetTree($TreeView1, $hHandle)
                    ; Convert to what we want to see
                    $sOutput = StringReplace($sTree, "|", ", ")
                    ; And print it
                    ConsoleWrite($sOutput & @CRLF)
                EndIf
            Next
    EndSwitch
WEnd

All clear?  Please ask if not. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...