Jump to content

Treeview And Multi-d Arrays


Gene
 Share

Recommended Posts

#cs

I want to populate a TreeView with data as described below. I haven't worked with arrays beyond 2D before. My question: is this a reasonable method or way off base?

I have the following data scenario...

there can be any number of Names,

each Name can have

any number of Activities

each Activity can have any number of Iterations

each Iteration can have an Overall Time

each Overall Time can have any number of Increments.

Local $aData [1] [1] [1] [1] [1]

$aData [Names] [Activities] [iTerations] [Overall time] [inCrements]

#CE

Local $n = 1, $a = 1, $t = 1, $o = 1, $c = 1

GUICreate("My GUI with treeview", 350, 215)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)

For $i = 1 To UBound ( $aData , 1 )

$aNames[$n] = GUICtrlCreateTreeViewItem($aData[$i], $treeview)

For $j = 1 To UBound ( $aData , 2 )

$Activity[$a] = GUICtrlCreateTreeViewItem($aData[$i][$j] , $aNames[$n])

For $k = 1 To UBound ( $aData , 3 )

$Iteration[$t] = GUICtrlCreateTreeViewItem($aData[$i][$j][$k] , $Activity[$a])

For $l = 1 To UBound ( $aData , 4 )

$OverAllTime[$o] = GUICtrlCreateTreeViewItem($aData[$i][$j][$k][$l] , $Iteration[$t])

For $m = 1 To UBound ( $aData , 5 )

$Increment[$c] = GUICtrlCreateTreeViewItem($aData[$i][$j][$k][$l][$m] , $OverAllTime[$o])

$c = $c + 1

$m = $m + 1

Next

$o = $o + 1

$l = $l + 1

Next

$t = $t + 1

$k = $k + 1

Next

$a = $a + 1

$j = $j + 1

Next

$n = $n + 1

$i = $i + 1

Next

When I searched the forum I got a lot of hits on TREEVIEW, but none that included 3D or more arrays.

Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

I don't think there's any problem with populating a treeview with arrays of many dimensions.

You can include the snippet in a code tag to make it easier to read.

I noticed that you're manually incrementing the For loop variables:

i = i + 1
j = j + 1
k = k + 1
l = l + 1
m = m + 1

When using a FOR loop, the variable initialized at the beginning of the for loop is automatically incremented when you specify "NEXT"

Edited by tonedeaf
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...