Sign in to follow this  
Followers 0
iAmNewbe

TreeView - How Add Sub Children?

22 posts in this topic

#1 ·  Posted (edited)

In the Help Docs for " _GUICtrlTreeView_Add " I understand pretty much the process there for creating and adding items to a TreeView. The problem I have is understanding how to add sub children to elements. In the example given it only adds a second level, A parent and a child level. What I need to do is add unlimited levels or sub children off of a tree. I do not understand how to do this.

Has anyone created a tutorial on this or can give me sample code to look at that shows how to do this?

I have read all the TreeView related threads here at the forums that I could find and have been looking at UDF's from various people but there is a lot of code there that I really don't want to mess with in my own application.

Here is a sample array I created that I want to create a TreeView from.

Local $List[9]
$List[1] = "Parent1"
$List[2] = "Parent1|sub1|sub2|sub3|sub4"
$List[3] = "Parent1|p1Sub1|p1Sub2"
$List[4] = "Parent2"
$List[5] = "Parent2|Sub1"
$List[6] = "Parent4"
$List[7] = "Parent4|Sub1|Sub2|sub3"
$List[8] = "Parent5"
$List[9] = "Parent5|Sub1|Sub2|Sub3|Sub4|Sub5|Sub6|Sub7|Sub8"

I created a FOR loop that walks through and outputs each row and splitting up individual items seperated by "|" but putting them into child "nodes" in a TreeView escapes me how to do that.

Using the sample code in the Help; snippit of that code below

_GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

It outputs a Tree like

Parent1
- sub1
- sub2
- sub3
- sub 4

What I want is this:

Parent 1
  - sub1
       - sub 2
          -sub 3
             - sub 4

Each sub item a child of the one before it. The code above just puts everything in one child node off the First Element in the row.

I looked up recursion examples but I honestly don't understand how to make that work with the TreeView functions.

I am confused how to do this. I don't fully understand the TreeView functions and how they work, I gather that

$hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)

$hItem is the hwnd of the new child? I really am confused because using a MsgBox I am able to output each item and they display fine, but they do not get added to Tree using

_GUICtrlTreeView_AddChild($hTreeView, $previous_item, $next_item, $iImage, $iImage)

Where $previous_item = sub1 and $next_item = sub2

$hItem = Parent1 on first go through the for loop; but looking at $hItem in MsgBox it displays "1"

This is how I thought this worked:

Trip 1 through the Loop

Parent1 is added to TreeView as a main parent item

Trip 2

sub1 is added to Parent1

Trip 3

sub2 is added to sub 1

Trip 4

sub3 is added to sub2

Trip5

sub4 is added to sub3

I created a For Loop that did just that, adding it to the sample above. Nothing happened.

Undoing this and using the example code with alteration to use my Array instead of random number of child elements it just did:

Trip 1

Parent1 is added to Tree

Trip 2

sub1 is added to Parent1

Trip 3

sub2 is added to Parent1

etc...

I tried several other arrangements to get what I wanted but nothing worked so I am posting here to ask for help on how you create unlimited sub children. Examples appreciated.

I can get this to work with normal LOOPS but they don't get put into the TreeView. I am lost and confused now.

Please help.

Thanks.

Edit: Attached Images of problem and what I want to happen

post-64573-0-60817400-1325983252_thumb.j

post-64573-0-63314300-1325983270_thumb.j

Edited by iAmNewbe

Share this post


Link to post
Share on other sites



Modifying the snip, this did what you asked for.

_GUICtrlTreeView_BeginUpdate($hTreeView)
For $x = 1 To Random(2, 10, 1)
  $iImage = Random(0, 5, 1)
  $hLast = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
  For $y = 1 To Random(2, 10, 1)
   $iImage = Random(0, 5, 1)
   $hLast = _GUICtrlTreeView_AddChild($hTreeView, $hLast, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
  Next
Next
_GUICtrlTreeView_EndUpdate($hTreeView)

But what your described after that seems like what you wrote should have worked. We can better spot the problem if you post your full code. :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks. I tested this and it worked but there is no association to children.

For example:

parent1|sub1|sub2

parent1|sub1|sub2|sub3

parent1|sub1|sub2|sub4

parent1|sub1|sub2|sub3|sub4

Instead of

parent1
   - sub1
       - sub2
          - sub3
              -sub4
          - sub4

It creates a new node row for each of the rows being run through the code. So there are 4 seperate tree entries instead of one that looks like I outlined above.

Can you help me understand how this is working? I see that each entry into the Tree has it's own hwnd and from what I can see they are all unique.

I screwed up my code so the results are completely wrong now but this will give you an idea of what I have been trying.

_GUICtrlTreeView_BeginUpdate($hTreeView)
for $x = 1 To $total_rows - 1
Local $row = _StringExplode($List[$x], "|", 0)
Local $cols = UBound($row)
  $iImage = Random(0, 5, 1)
  If $cols == 1 Then
  $hLast = _GUICtrlTreeView_Add($hTreeView, 0, $row[0], $iImage, $iImage)
  $hParent = $hLast
  EndIf
  For $y = 0 To $cols - 1
if $y == $cols - 1 Then ExitLoop
   $iImage = Random(0, 5, 1)
   $hLast = _GUICtrlTreeView_AddChild($hTreeView, $hLast, $row[$y], $iImage, $iImage)
  Next
  $hLast = $hParent
Next
_GUICtrlTreeView_EndUpdate($hTreeView)

FULL CODE Below

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <String.au3>

DIM $List[7]
$List[0] = "parent1"
$List[1] = "parent1|sub1|sub2"
$List[2] = "parent1|sub1|sub2|sub3"
$List[3] = "parent1|sub1|sub2|sub4"
$List[4] = "parent1|sub1|sub2|sub3|sub4"
$List[5] = "parent1|sub1|sub2|sub3|sub5"
$List[6] = "parent1|sub1|sub2|sub5"

_Main($List)

Func _Main($List)
    Local $total_rows = UBound($List)
    Local $hItem, $hImage, $iImage, $hTreeView, $hLast, $hParent
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
    GUICreate("TreeView Add", 400, 300)
    $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState()
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)
_GUICtrlTreeView_BeginUpdate($hTreeView)
for $x = 1 To $total_rows - 1
Local $row = _StringExplode($List[$x], "|", 0)
Local $cols = UBound($row)
  $iImage = Random(0, 5, 1)
  If $cols == 1 Then
  $hLast = _GUICtrlTreeView_Add($hTreeView, 0, $row[0], $iImage, $iImage)
  $hParent = $hLast
  EndIf
  For $y = 0 To $cols - 1
if $y == $cols - 1 Then ExitLoop
   $iImage = Random(0, 5, 1)
   $hLast = _GUICtrlTreeView_AddChild($hTreeView, $hLast, $row[$y], $iImage, $iImage)
  Next
  $hLast = $hParent
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main
Edited by iAmNewbe

Share this post


Link to post
Share on other sites

Does anyone have any tutorials on how to do this sort of thing and/or on setting up TreeView properly? I am really confused on how you reference children nodes when adding new ones like what i am attempting to do above.

Thanks for any help.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

iAmNewbe, just delete this line from the full code in post #3

If $y = $cols - 1 Then ExitLoop

If you run the code sample above you will see that each row passed in is being placed on a new level and not being added to the actual child level.

That line you suggested to remove was added in an attempt to see if it would stop each new row in $List array to a new tree. It didn't and instead caused different issues. Removing that line demonstrates the problem I am having with adding new child nodes and not having them correctly added to the correct child node.

If that didn't make sense let me know and I will try to explain it better.

Thanks for your response.

Edit: Attached Screenshot of what I am trying to explain. If you look at the attached JPG instead of adding child nodes to the first parent1 row, which is what should be happening, instead it creates an entirely new row which is not what I want.

post-64573-0-28769800-1325981085_thumb.j

Edited by iAmNewbe

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I'm not following you. You said:

What I want is this:

Parent 1

- sub1

- sub 2

-sub 3

- sub 4

Make a drawing or something - it's easier to understand what you want to achieve.

edit: bad formating

Edited by taietel

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Ok I'm also getting confused on what you want and which part you dont understand. :) When you said there are 4 seperate tree entries for:

parent1|sub1|sub2
parent1|sub1|sub2|sub3
parent1|sub1|sub2|sub4
parent1|sub1|sub2|sub3|sub4

In my eyes there should be 4 entries. Each entry having sub entrys that are children of the previous.

Does this do what you want?

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <String.au3>
Dim $List[7]
$List[0] = "parent1"
$List[1] = "parent1|sub1|sub2"
$List[2] = "parent1|sub1|sub2|sub3"
$List[3] = "parent1|sub1|sub2|sub4"
$List[4] = "parent1|sub1|sub2|sub3|sub4"
$List[5] = "parent1|sub1|sub2|sub3|sub5"
$List[6] = "parent1|sub1|sub2|sub5"
_Main($List)
Func _Main($List)
Local $hItem, $hImage, $iImage, $hTreeView, $hLast, $hParent
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
GUICreate("TreeView Add", 400, 300)
$hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, "shell32.dll", 110)
_GUIImageList_AddIcon($hImage, "shell32.dll", 131)
_GUIImageList_AddIcon($hImage, "shell32.dll", 165)
_GUIImageList_AddIcon($hImage, "shell32.dll", 168)
_GUIImageList_AddIcon($hImage, "shell32.dll", 137)
_GUIImageList_AddIcon($hImage, "shell32.dll", 146)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)

_GUICtrlTreeView_BeginUpdate($hTreeView)

;Go through each element in $list
For $i = 0 to UBound($List) - 1
  ;split up each element in $list
  Local $aTree = StringSplit($List[$i], "|", 0); $aTree[0] contains total number of elements
  ;generate random icon
  $iImage = Random(0, 5, 1)
  ;add new node
  $hMainParent = _GUICtrlTreeView_Add($hTreeView, 0, $aTree[1], $iImage, $iImage)
  ;if more than one item, loop through each item adding it as a child to the previous child.
  If $aTree[0] > 1 Then
   $hLast = $hMainParent
   For $j = 2 to $aTree[0]
    $hLast = _GUICtrlTreeView_AddChild($hTreeView, $hLast, $aTree[$j], $iImage, $iImage)
   Next
  EndIf
Next
_GUICtrlTreeView_EndUpdate($hTreeView)

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc   ;==>_Main
Edited by Beege

Share this post


Link to post
Share on other sites

iamnewb,

Does this look like what you want?

;
;
;

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>

GUICreate("TreeView", 500,500)

Local $tv    =  GUICtrlCreateTreeView(10, 10, 200, 250, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
Local $p1    =  GUICtrlCreateTreeViewItem("Parent1", $tv)
                GUICtrlSetColor(-1, 0xff0000)
Local $c11   =  GUICtrlCreateTreeViewItem("child #1", $p1)
                GUICtrlSetColor(-1, 0xff0000)
Local $gc11  =  GUICtrlCreateTreeViewItem("grandchild #1", $c11)
                GUICtrlSetColor(-1, 0xff0000)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

If so, the tree structure can be constructed programmatically ( similar to what Beege is doing)...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Hello Kylomas,

I added images to my OP that shows what it is I am trying to do. Basically add new nodes to a tree and have them be placed under the correct child and parent.

Your sample code is the direction I am trying to make this go but I don't understand how to do that apparently. The closest example I guess is a directory structure of a hard disk where you get the full path for each folder and file and then create a Tree View from that. In my case I am not creating a hard disk folder tree but the anaology is same I guess.

The $List array I used in my sample above is just ONE parent and then children, grand children, great grandchilldren, great great grand children and so on and so forth are being added automatically no matter where or what order the actual data is coming in.

I don't know how to do that and am getting instead what Beege is showing in his code sample above, which is not what I want. It should be more like what you showed with the tree structure spread out under one parent instead of duplication of the same parent multiple times. Take a look at the original post at the bottom and you will see the Images I made that detail what it is I am trying to get done.

Thank you for your responses.

Share this post


Link to post
Share on other sites

Ok I'm also getting confused on what you want and which part you dont understand. :) When you said there are 4 seperate tree entries for:

parent1|sub1|sub2
parent1|sub1|sub2|sub3
parent1|sub1|sub2|sub4
parent1|sub1|sub2|sub3|sub4

In my eyes there should be 4 entries. Each entry having sub entrys that are children of the previous.

Does this do what you want?

Nope. There is one parent1. What this code is doing is duplicating that parent1 and all the other children and placing each array element into a seperate level instead of updating the single parent1 element and it's children.

parent1   <--  parent gets created
parent1|sub1   <--  sub1 child gets added under parent1
parent1|sub1|sub2   <--  sub2 child is added under sub1
parent1|sub1|sub2|sub3   <--  sub3 child is added under sub2
parent1|sub1|sub2|sub4   <--  sub4 child is added under sub2
parent1|sub1|sub2|sub3|sub4  <--  sub4 child is added under sub3 above

When you look at the tree structure there is a single parent1 folder when you open up that there is a sub1 child.

sub1 contains sub2

sub 2 contains sub3 and sub4 folders

sub3 contains sub4

Now if later children are added to what is already there then the new entries should automatically be added underneath the correct child or grandchild or great grand child or whatever you want to call them nodes.

The elements within $List array are full paths to the new node location which needs to be added to that particular position within the tree structure.

I hope this makes it more clear. I also attached images in my original post to show what it is should happen with this specific example.

Thanks for you responses and help.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

In your post you said "I want this"

Parent 1
  - sub1
       - sub 2
          -sub 3
             - sub 4

Can you do the same thing again? Post exactly what you expect to see if using this data:

$List[0] = "parent1"
$List[1] = "parent1|sub1|sub2"
$List[2] = "parent1|sub1|sub2|sub3"
$List[3] = "parent1|sub1|sub2|sub4"

Edit: We posted at the same time. I see what you mean.

Edited by Beege

Share this post


Link to post
Share on other sites

If an item has already been added, then don't re-add it to the delimited list. Also to do what you want, use 2 different delimeters. "|" for child items, and I chose ";" for additional child items.

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <String.au3>
Dim $List[1]
;~ parent1   <--  parent gets created
;~ parent1|sub1   <--  sub1 child gets added under parent1
;~ parent1|sub1|sub2   <--  sub2 child is added under sub1
;~ parent1|sub1|sub2|sub3   <--  sub3 child is added under sub2
;~ parent1|sub1|sub2|sub4   <--  sub4 child is added under sub2
;~ parent1|sub1|sub2|sub3|sub4  <--  sub4 child is added under sub3 above
$List[0] = "parent1|sub1|sub2|sub3;sub4|sub5"
_Main($List)
Func _Main($List)
Local $hItem, $hImage, $iImage, $hTreeView, $hLast, $hParent
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
GUICreate("TreeView Add", 400, 300)
$hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, "shell32.dll", 110)
_GUIImageList_AddIcon($hImage, "shell32.dll", 131)
_GUIImageList_AddIcon($hImage, "shell32.dll", 165)
_GUIImageList_AddIcon($hImage, "shell32.dll", 168)
_GUIImageList_AddIcon($hImage, "shell32.dll", 137)
_GUIImageList_AddIcon($hImage, "shell32.dll", 146)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)
_GUICtrlTreeView_BeginUpdate($hTreeView)
;Go through each element in $list
For $i = 0 to UBound($List) - 1
  ;split up each element in $list
  Local $aTree = StringSplit($List[$i], "|", 0); $aTree[0] contains total number of elements
  ;add new node
  $iImage = Random(0, 5, 1)
  $hMainParent = _GUICtrlTreeView_Add($hTreeView, 0, $aTree[1], $iImage, $iImage)
  ;if more than one item, loop through each item adding it as a child to the previous child.
  If $aTree[0] > 1 Then
   $hLast = $hMainParent
   For $j = 2 to $aTree[0]
  $hLastSub = $hLast
  ;if that subitem has additional sub items, split up those and add
  $aExtraSubitems = StringSplit($aTree[$j], ';')
  For $k = 1 to UBound($aExtraSubitems)-1
   $iImage = Random(0, 5, 1)
   $hLastSub = _GUICtrlTreeView_AddChild($hTreeView, $hLastSub, $aExtraSubitems[$k], $iImage, $iImage)
  Next
   Next
  EndIf
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc   ;==>_Main

Share this post


Link to post
Share on other sites

In your post you said "I want this"

Parent 1
  - sub1
       - sub 2
          -sub 3
             - sub 4

Can you do the same thing again? Post exactly what you expect to see if using this data:

$List[0] = "parent1"
$List[1] = "parent1|sub1|sub2"
$List[2] = "parent1|sub1|sub2|sub3"
$List[3] = "parent1|sub1|sub2|sub4"

Edit: We posted at the same time. I see what you mean.

I did you one better. I made an image, attached it to my main OP above.

Thanks for your help.

Also this is just one parent node example.

The elements within the array are full paths to the new tree node. So

$List[1] = "parent1|sub1|sub2"

sub2 is being added to sub1 which is a direct child of parent1

$List[0] = "parent1"
$List[1] = "parent1|sub1"
$List[2] = "parent1|sub1|sub2"
$List[3] = "parent1|sub1|sub2|sub3"
$List[3] = "parent1|sub1|sub2|sub3|sub4"
$List[4] = "parent1|sub1|sub2|sub4"
$List[5] = "parent2"
$List[6] = "parent2|sub1"
$List[7] = "parent2|sub1|sub2"
$List[8] = "parent2|sub1|sub2|sub3"
$List[9] = "parent2|sub1|sub2|sub3|sub4"
$List[10] = "parent2|sub1|sub2|sub4"
$List[11] = "parent3"
$List[12] = "parent3|sub1"
$List[13] = "parent3|sub1|sub2"
$List[14] = "parent3|sub1|sub2|sub3"
$List[15] = "parent3|sub1|sub2|sub3|sub4"
$List[16] = "parent3|sub1|sub2|sub4"
$List[17] = "parent4
$List[18] = "parent4|sub1"

The above is 4 folders

parent1

parent2

parent3

parent4

When you look at the treeview there are only 4 folders and no duplication of any of the parents.

NO

parent1

parent1

parent1

parent2

parent2

parent2

etc...

Looking at the array above now, you should see the pattern of what is going on.

Element in the array starting with parent1 that is the main parent node for that structure

looking at the parent1's you see each element in the array adds a new child level which all fall under that specific parent tree

Going back to my hardisk example it is like

C:\Windows\System32\cache

where each segment seperator "" is a new child level parented off of "c:"

so

c:windows

c:windowssystem32

C:\Windows\System32\cache

C:\Windows\System32\icon

c:windowstemp

when you look at the tree structure for this example you only see

+c:

Then

-c:
    |
    -- windows

Then

-c:
    |
    -- windows
                   |
                   -- system32
                   -- temp

etc etc...

Make it more clear?

The actual implementation I probably am not doing right but I am just now learning how to setup and use the TreeView functions and it is confusing me or I am confusing me.. LOL

Thanks for all your help though, it is much appreciated.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Are you making this to display directorys? if so theres already a great UDF by Yashied just for that. :)

Edited by Beege

Share this post


Link to post
Share on other sites

@Beege,

Spitballing this...

seems like a 2d array where d0 = parent and d1 = child should work...

like

]

$tree[10][2]
$tree[0][0] = "node 1"
$tree[0][1] = "child1"
$tree[1][0] = "child1"   ; child1 now becomes the parent of child2
$tree[1][1] = "child2"

trying to get this to work in code...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Are you making this to display directorys? if so theres already a great UDF by Yashied just for that. :)

Nope, but it could be used for that I suppose. I haver looked at that and a few other udf's for directory displaying but I didn't understand how to use them for non directory data. Plus I want to understand how this works so with your help I am getting a better understanding.

I am playing with your code now, it seems to work but the problem is that the data I am putting into this comes on it's own seperate line in a text file in the "full path" format I have been using in my List Array sample. I can break them up more but it would be simpler to have a function that just took in what it is given via each row in the array and adds appropriately to the Tree.. Though, like I said my thinking here may not be correct in how I am looking at the problem.

I was beginning to see that I needed more variables to work with here from what I was trying with adapting the help documentation sample code.

You are helping me a lot though, I really appreciate the comments you added to your code that explains what you are doing. I am more trying to understand how to go about this and how this works than having entire functions created for me but it is all helping me learn so I really much appreciate this.

Share this post


Link to post
Share on other sites

I can break them up more but it would be simpler to have a function that just took in what it is given via each row in the array and adds appropriately to the Tree..

I dont think creating that function you want that appropriately adds to the treeview is going to be easier. Breaking up the data as its beening given to you sounds easier to me. Thats just me though. Is the data being created by another script of yours?

Share this post


Link to post
Share on other sites

iamanewbe,

Does'nt post # 16 express that very idea...?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

@Kylomas, Your idea is good. The concept of your idea is pretty much the same as mine, only in my example I am passing the 2d array in string form.

;as string
$sList = "parent1|sub1|sub2|sub3;sub4|sub5"

;as 2d array
$aList[0][0] = "parent1"
$aList[1][0] = "sub1"
$aList[2][0] = "sub2"

$aList[3][0] = "sub3"
$aList[3][1] = "sub4"

$aList[4][0] = "sub5"

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