Jump to content

list items to a treeview item


Recommended Posts

$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

Link to comment
Share on other sites

  • Moderators

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

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 comment
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)

Link to comment
Share on other sites

  • Moderators

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

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 comment
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

Link to comment
Share on other sites

  • Moderators

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

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 comment
Share on other sites

  • Moderators

Velnes,

luv u :}

Merely platonic I trust! :)

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 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...