Sign in to follow this  
Followers 0
Velnes

list items to a treeview item

9 posts in this topic

$FileList = _FileListToArray(@DesktopDir)
$avArray[0] = $FileList[0]
$avArray[1] = $FileList[1]
$avArray[2] = $FileList[2]
$items[1] = GUICtrlCreateListViewItem($FileList[1], $tree)
$items[2] = GUICtrlCreateListViewItem($FileList[2], $tree)


GUICtrlSetData($items[0], $avArray[1])
GUICtrlSetData($items[0], $avArray[2])

thats wat i cant figure out...

how do u make like just one $items[x]

so that it repeats from that one tself to like 99 max

and same for $avArray[x]

im not good at this thing at all

i just dont want script to be with 99 lines of $items[1] $items[2] so on ...

maybe there is a way to make just one $avArray[x] which will be as all of avArrays from 1 to 99 ? i hope u get my question thnx for readin

Share this post


Link to post
Share on other sites



Velnes,

You need to look at For...Next in the Help file. :)

These 2 commands produce loops which allow you to repeat commands a certain number of times. In your example you would do something like this:

$FileList = _FileListToArray(@DesktopDir)

For $i = 1 To $FileList[0] ; Tell AutoIt to start at 1 and go up to the value of $FileList[0]

    $avArray[$i] = $FileList[$i] ; $i will increase each time you go round the loop
    $items[$i] = GUICtrlCreateListViewItem($FileList[$i], $tree)
    GUICtrlSetData($items[$i], $avArray[$i])

Next ; AutoIt automatically increases the value of $i here until it reaches the value of $FileList[0]

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

yes,al clear :) didnt know u can do for $i = 1 to $soemthing[number]

didnt u can do like that :P well there is a first time for everything and everyone :D thnxalot u helped me very much :)

Share this post


Link to post
Share on other sites

ok anotehr problem..just got back from school and tryed solving this thig.. whith variables i cant get it to read the currently selected item text...

Global $avArray[99], $items[99], $FileList[99]   
$FileList = _FileListToArray(@desktopdir)

$tree = GUICtrlCreateListView("testtttt",0, 50, 250, 200)

For $i = 1 To $FileList[0] ; Tell AutoIt to start at 1 and go up to the value of $FileList[0]

    $avArray[$i] = $FileList[$i] ; $i will increase each time you go round the loop
    $items[$i] = GUICtrlCreateListViewItem($FileList[$i], $tree)
    GUICtrlSetData($items[$i], $avArray[$i] & "|" & "test")
Next ; AutoIt automatically increases the value of $i here until it reaches the value of $FileList[0]


$test = GUICtrlCreateButton("run test", 5, 5, 100, 20)


GUISetState(@SW_SHOW)


While 1
    Switch GUIGetMsg()
    Case $test
        MsgBox(0, "",  GUICtrlRead($items[$i]))
    EndSwitch
WEnd

so when i press run test button it wont show me the text of the line selected in that treeview.. i get 0 all the time...

thnx for help (handshake)

Share this post


Link to post
Share on other sites

Velnes,

As explained in the Help file you need to use GUICtrlRead on the ListView to get the ControlID if the selected item and then use GUICtrlRead again on that. :)

Looks a bit cumbersome but it works:

#include <GUIConstantsEx.au3>
#include <File.au3>

Global $avArray[99], $items[99], $FileList[99]

$FileList = _FileListToArray(@DesktopDir)

GUICreate("Test", 500, 500)

$tree = GUICtrlCreateListView("testtttt", 0, 50, 250, 200)

For $i = 1 To $FileList[0]

    $avArray[$i] = $FileList[$i]
    $items[$i] = GUICtrlCreateListViewItem($FileList[$i], $tree)
    GUICtrlSetData($items[$i], $avArray[$i] & "|" & "test")

Next

$test = GUICtrlCreateButton("run test", 5, 5, 100, 20)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $test
            MsgBox(0, "", GUICtrlRead(GUICtrlRead($tree))) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    EndSwitch
WEnd

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

haha lol i was trying the double guictrlread thing but didnt work for me.. coz i did with $items[$i] :DDDD lol wata failer i am...

but hmm when the text is there in msgbox it also adds that ' | ' character at end.. how to remove that :) i dont actualy see anything in code wat could cause this to appear

lol sorry for my stupidity but this thing is my worst nightmare since i never used treeview

Share this post


Link to post
Share on other sites

Velnes,

i never used treeview

And you are not using one now - you are using a ListView whcih is a very different beast. :)

You get the "|" because the return value splits the columns using that character. I know you only have 1 column, but it still appears. Just use StringTrimRight to get rid of it. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

aww ok :) thnx very much ! :) luv u :}

Share this post


Link to post
Share on other sites

Velnes,

luv u :}

Merely platonic I trust! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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