![]() |
Interesting Treeview problem.
Does somebody have a routine that finds the order of the nodes in a Treeview
control, using the indices and parent indices, but not using the actual treeview? I have an array with in column one the index of the nodes and in column 2 the parent index of the nodes. The array is ordered ascending on column one. What I have to do is get the order of the nodes in column three, using only the information in columns one and two of the array. With order of the nodes I mean the order they appear on the screen from top to bottom. This an example of the array where this has been done: 1 1 2 1 2 3 2 3 4 3 4 5 3 10 6 3 11 7 3 13 8 3 14 9 3 15 10 3 16 11 3 17 12 6 12 13 3 18 14 13 19 15 3 22 16 3 23 17 16 24 18 3 25 19 18 26 20 18 27 21 20 28 22 3 29 23 22 30 24 22 31 25 24 32 26 22 33 27 26 34 28 26 35 29 28 36 30 13 20 31 30 21 32 3 37 33 32 38 34 4 5 35 34 6 36 34 7 37 34 8 38 37 9 Thanks for any assistance. |
Interesting Treeview problem.
I think I figured this out by looking at a similar routine, passsed to me by
somebody on the newsgroup a while ago, that works on the actual treeview. The index is in column 1, the parent index in column 4 and the order goes in column 5 NC is the nodecount of the treeview. Sub OrderTest(ByVal Idx As Byte, NC As Byte) Dim n As Byte Static n2 As Byte Static counter As Byte If Idx = 1 Then SearchValuesArray(1, 5) = 1 counter = 2 End If 'look for child nodes first '-------------------------- For n = Idx To NC If SearchValuesArray(n, 4) = Idx Then 'found child node '---------------- SearchValuesArray(n, 5) = counter counter = counter + 1 'look for the child of this child '-------------------------------- OrderTest SearchValuesArray(n, 1), NC End If Next n2 = n 'look for sibling nodes '---------------------- For n = n2 To NC If SearchValuesArray(n, 4) = Idx Then 'found sibling '------------- SearchValuesArray(n, 5) = counter counter = counter + 1 'look for children again '----------------------- OrderTest SearchValuesArray(n, 1), NC End If Next End Sub And call this sub like this. Sub ordertest2() OrderTest 1, 38 End Sub I might make it a bit more efficient, but it does work. RBS "RB Smissaert" wrote in message ... Does somebody have a routine that finds the order of the nodes in a Treeview control, using the indices and parent indices, but not using the actual treeview? I have an array with in column one the index of the nodes and in column 2 the parent index of the nodes. The array is ordered ascending on column one. What I have to do is get the order of the nodes in column three, using only the information in columns one and two of the array. With order of the nodes I mean the order they appear on the screen from top to bottom. This an example of the array where this has been done: 1 1 2 1 2 3 2 3 4 3 4 5 3 10 6 3 11 7 3 13 8 3 14 9 3 15 10 3 16 11 3 17 12 6 12 13 3 18 14 13 19 15 3 22 16 3 23 17 16 24 18 3 25 19 18 26 20 18 27 21 20 28 22 3 29 23 22 30 24 22 31 25 24 32 26 22 33 27 26 34 28 26 35 29 28 36 30 13 20 31 30 21 32 3 37 33 32 38 34 4 5 35 34 6 36 34 7 37 34 8 38 37 9 Thanks for any assistance. |
All times are GMT +1. The time now is 10:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com