monoscout999 Posted August 18, 2011 Share Posted August 18, 2011 (edited) Hello forum, i am tryning to fill a treeview with folders and files, i am using a recursive method taken from Here i am editing and editing but i can`t figure out how to make it work properly... the problem is that i don`t know how to put every item where should be.Maybe someone else has look this before in the forum, i guess that is a common usage for a treeview, i`ve searched but i don`t find anything.I attach a RAR with a couple of folders and TXT files for test propouses and my attempt script.TREEVIEW.rar Edited August 18, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
smartee Posted August 18, 2011 Share Posted August 18, 2011 hi, The solution is simpler than you may have thought. Using the same example from the wiki by Melba23, expandcollapse popup#include <GuiTreeView.au3> $hGui = GUICreate("Demo1", 600, 400) $hTreeView = _GUICtrlTreeView_Create($hGui, 10, 10, 580, 380) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) ListFiles_ToTreeView(@ScriptDir, 0) _GUICtrlTreeView_EndUpdate($hTreeView) Do Until GUIGetMsg() = -3 Func ListFiles_ToTreeView($sSourceFolder, $hItem) Local $sFile ; Force a trailing \ If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\" ; Start the search Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*") ; If no files found then return If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Now run through the contents of the folder While 1 ; Get next match $sFile = FileFindNextFile($hSearch) ; If no more files then close search handle and return If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Check if a folder If @extended Then ; If so then call the function recursively ListFiles_ToTreeView($sSourceFolder & $sFile, _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile)) Else ; If a file than write path and name _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile) EndIf WEnd ; Close search handle FileClose($hSearch) EndFunc ;==>ListFiles_ToTreeView Now sigh and say of course, why didn't I try that? -smartee Link to comment Share on other sites More sharing options...
monoscout999 Posted August 19, 2011 Author Share Posted August 19, 2011 I was so close.... well almost... thanks smartee Link to comment Share on other sites More sharing options...
izzy12 Posted December 13, 2011 Share Posted December 13, 2011 I was searching and search for a way to do AND BAM !!!! I find this. now is it possible to display/edit the highlighted file from the treeview in a edit box and save the changes made? Link to comment Share on other sites More sharing options...
taietel Posted December 13, 2011 Share Posted December 13, 2011 Yes, it is: just look for _GUICtrlTreeView_GetCount, _GUICtrlTreeView_GetState, FileRead, GuiCtrlCreateEdit, GuiCtrlSetData, GuiCtrlRead, FileOpen, FileWrite, FileClose in the Help file. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now