Jump to content

TreeView: Duplicate items with the same name


Recommended Posts

Hi, like what I have done with ListView recently, I managed to add a list of Folders => Subfolder => Files into ListView and now I'm moving to TreeView. The problem is when the subfolder has more than one file, my code creates 2 same name item instead.

$aList = _RecFileListToArray(@ScriptDir & "\test", "*.txt;*.pxt;*.bee", 1, 1, 1, 1)

; Loop through file list
For $i = 1 To $aList[0]
   Local $j = 1, $cItem[4]
   ; Split path on "\"
   $aSplit = StringSplit($aList[$i], "\")
   $pItem = GUICtrlCreateTreeViewItem($aSplit[1], $TreeView)
   $cItem[1] = $pItem
   While $aSplit[0] > $j
      $j += 1
      $cItem[$j] = GUICtrlCreateTreeViewItem($aSplit[$j], $cItem[$j-1])
   WEnd
Next
By the way, I really want to get the full file link when doubleclick on its name in my TreeView, still thinking... Edited by DucViet321
$Money = ControlGetMoney(@Life,"People","Pocket4")If $Money Then $Rich = TrueElse $Risk = True _RunAwayFromPolice("Fastest")EndIf
Link to comment
Share on other sites

@FireFox: Here you go, Its not quiet nice cuz I removed things which are not related

#include <RecFileListToArray.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>

$Form = GUICreate("Beenice 2", 729, 557, 339, 228)
$TreeView = GUICtrlCreateTreeView(0, 30, 225, 485)
GUISetState(@SW_SHOW)

; Get sorted list of files
$aList = _RecFileListToArray(@ScriptDir & "\test", "*.txt;*.pxt;*.bee", 1, 1, 1, 1)

; Loop through file list
For $i = 1 To $aList[0]
   Local $j = 1, $cItem[4]
   ; Split path on "\"
   $aSplit = StringSplit($aList[$i], "\")
   $pItem = GUICtrlCreateTreeViewItem($aSplit[1], $TreeView)
   $cItem[1] = $pItem
   While $aSplit[0] > $j
      $j += 1
      $cItem[$j] = GUICtrlCreateTreeViewItem($aSplit[$j], $cItem[$j-1])
   WEnd
Next
;~  _ArrayDisplay($aList)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Form
    EndSwitch
WEnd
*RecFileListToArray by M23: '?do=embed' frameborder='0' data-embedContent>>

Duc Viet

Edited by DucViet321
$Money = ControlGetMoney(@Life,"People","Pocket4")If $Money Then $Rich = TrueElse $Risk = True _RunAwayFromPolice("Fastest")EndIf
Link to comment
Share on other sites

How do you want the files to be listed?

Br, FireFox.

Simple:

 

[+] Folder 1

-----[+] Subfolder

----------- File

----------- File

----------- File

----------- File

-----[+] Subfolder

----------- File

[+] Folder 2

-----[+] Subfolder

-----------[+] Subsubfolder

----------------- File

 

I've done it but if the main folders are same name, these aren't mergred

$Money = ControlGetMoney(@Life,"People","Pocket4")If $Money Then $Rich = TrueElse $Risk = True _RunAwayFromPolice("Fastest")EndIf
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...