Hi David,

    The text in the tree view is the stuff you see being said on the tree. The 
data, is the ID tag for that item selected.
    Now, when you go down another level, you deciding the data to reflect the 
level.
    Suppose you have on the main list 10 items, OK?
    Then on the second level you have no more than 10 items, OK?
    The the third level you also have 10 items, OK?
    Now you are dealing with powers of 10, or 0 to 9. So, you have 3 levels so 
each ID tag of each level would be a power of 10, or if your selected item is 
19, OK?
    Then you are item 1 of the first level and the 9'th, actually 10'th item of 
the second level, OK?

    This is how you set your check box, which does not exist, but the tree 
view, or limb you follow is the value of the data item at that point.

    This is what I had sent you and yes, what I sent you is confusing, but the 
guts of that is the beginning of the MainProc where I start doing that level 
check; but you have to understand my program to get there.

    so, as I have mentioned above, set your data value to show the full  amount 
of data, checks at the tree view level you are opened up to.

    In this case you only have one item selected at each level and that is all 
you can do in a tree view, but since you are selecting a sub value of a main 
level, you do not need anything more than that. For that is the meaning of a 
tree view, following a tree limb...


    I hope this helps. I will send or post the tree view items and how to make 
them, there are only 2 or 3 places where that happen, one place where the main 
menu is made into categories, then the listing of file names or programming 
names in the second level, and the third level is the info supplied for each 
program. This is what I did in the UnInstall program.

    So, the text is what is displayed and said when you move through the tree 
view, the data is the ID tag for each and every item on the tree and you make 
up the rules for that.
    As I said, using the power of 10 only allows 10 items for each sub level. 
You can expand that as I did to indicate up to a 1000 at each level which means 
you are going down each level as a power of 3 each. You can make it even large, 
each call to the subroutine must reflect that choice.
    But ID tags can be words as well if you choose to do so...

    I hope this helps, next I will send the exact 2 programs that do this for 
you, along with the controlling top level loop...

        Sincerely
        Bruce A. Babcock



  Sent: Thursday, April 11, 2013 7:18 PM
  Subject: Re: Treeview Questions - Still attempting to learn :)


  As regards to my prior message, I have solved issue number 3, how to quickly 
iterate
  the whole tree-structure. Still, my other questions remain open.
  But for what it is worth, and to all who might benefit from a quick way of 
running
  through all the possible items on a tree, here I am pasting in the sub 
routine, that
  will do the whole iteration. It is not more than a few lines of coding, and 
will
  do with any number of branches and leaves, from what I can see. In the pasted 
example,
  the actual line of interest, is the Speak line, which will read out the Text 
property
  of the individual item. You can replace this line, with any other activity 
you want
  performed on the individual item. The sub will take a TreeviewItems object, 
as its
  parameter. If you want the whole treeview iterated, from root and out, you 
could
  simply do something like:
      IterateTree TreeviewObject.TopLevel
  Where TreeviewObject is an object pointing to a treeview, that you have 
defined.
  In my testing app, I called it from the DialogEventHandler function of my 
testing
  dialog. Here I have defined a treview control, named TV_Test, and the sub is 
called
  when a button "BTN_SpeakTree) is pressed. The snip-it of the 
DialogEventHandler then
  looks like this:
      Case "BTN_SpeakTree"
          If DEvent = ButtonClicked Then
              IterateTree DObj.Control( "TV_Test" ).TopLevel
              DialogEventHandler = True
              Exit Function
          End If 'BTN_SpeakTree.
  And, here is the iteration sub:
  Sub IterateTree( TVItems)
   Dim CurrentItem: Set CurrentItem = Nothing
   Dim ItemNumber
   For ItemNumber = 1 To TVItems.Count
    Set CurrentItem = TVItems.Item( ItemNumber)
  ' The following line, is the actual action, performed on the individual item. 
Replace
  it with whatever you want:
    Speak CurrentItem.Text  &","
    If CurrentItem.Children.Count >=1 Then
     IterateTree CurrentItem.Children
     Set currentItem = Nothing
    End If 'CurrentItem.Children.Count >=1.
   Next 'ItemNumber.
  ' Room Cleaning:
   If Not CurrentItem Is Nothing Then Set CurrentItem = Nothing
   If Not TVItems Is Nothing Then Set TVItems = Nothing
  End Sub 'IterateTree.
  Hope all of this will be of any help for the rest of the community. I am 
sure, things
  can be modified to work even more smoothly, and that you can change whatever 
part
  of it, to fit your personal scripting needs. But at least, I wanted to share 
this,
  since it is not something that first comes to mind, how to handle. Enjoy it. 
And
  if anyone has any feedback on the other issues I presented in the initial 
message
  of mine, I am all greatful for whatever feedback you may have.
  Thanks again,
  ----- Original Message -----
  From:
  David
  To:
  [email protected]
  Sent: Thursday, April 11, 2013 11:14 PM
  Subject: Treeview Questions - Still attempting to learn :)
  I am still trying to wrap my brain around the complexity of a treeview, and 
how to
  gain the fullest benefit from this kind of control. Earlier, when asking, one 
of
  you send me a code snip-it from one of his apps, holding some 600 lines. 
Thanks to
  you, and it got me somehow going. Yet, I don't follow all of your thinking, 
or the
  reason why you do this and that. That is one of the drawbacks of 600 lines of 
coding.
  Smile.
  Allright, I have got that far, that I am able to fill in the information on 
the tree,
  and get it displayed in my dialog. So far, this works satisfactory. Now, I am 
stuck
  with a few challenges, most of all when comes to retrieve the needed 
information
  from the treeview. I have a feeling, most of my getting stuck here, is due to 
a lack
  of understanding. That's why, I hoped to have some clarification on the 
following
  questions.
  1. What is the exact benefit of the Text, as compared to the Data, field in a 
treeview
  item. OK, I do get the fact, that in case the same text could happen to be on 
several
  branches or leaves of the tree, the Data field could be used to distinguish 
the one
  occurrance from the other. But if i have a tree, where no text will appear 
more than
  once, is there any reason why I should bother about filling in the data field 
for
  each item? I.e, would there be any search feature or the like, that could be 
quicker
  done by iterating the tree-structure on the Data fields, compared to simply 
just
  concentrating on the Text fields.
  2. The treeview I am building, has checkboxes, which the user can check for 
each
  item on the tree. I have searched the Reference manual, but not sure if I 
have overlooked
  anything. From what I can see, there is no way in determining whether a 
treeview
  Item has been checked or not. I see the Selected feature, but from what my 
testing
  leads me to understand, this simply let's me know when an item has focus 
(that is,
  when the cursor is placed on the item, the Selected feature will be set). Is 
it correct,
  that there is no build-in feature, that would "fire", when a treeview item 
has been
  checked or unchecked? If this is the case, technically, why? We have features 
for
  Checkboxes, which will tell us when it is checked and not - and we have 
similar features
  for a multi-selection listbox. Why would there be no feature set, whenever a 
treeview
  item is checked?
  3. Does anyone have a simple quick iteration routine, for "rushing" through a 
whole
  treeview, including all its branches and leaves. My treeview, might hold as 
much
  as 9 sublevels, in addition to the root. And it might hold different amounts 
of entries
  on each branch or sublevel. I guess the best would be to use some For...Next 
loops,
  and somehow retrieve the Count property for each branch. But I have run my 
head into
  the wall, as to how to get through absolutely all the possible items on the 
tree.
  I guess, that is the one way to go, when iterating the different items, or am 
I totally
  lost in such an approach? Say for instance, the user would have been given 
the chance
  of searching for a given text, which would be the Text property of an item on 
the
  tree. I then guess, I will have to iterate all the current items on the tree, 
looking
  out for that particular text. And, that is why, I wondered if there was a 
simple
  routine, that would perform such a "run-through", with relatively few lines 
of coding.
  Yep, I did read through I don't know how many pages, in the Reference manual, 
and
  I have been looking through quite a few lines of existing coding. I am sure, 
I can
  get on with this, if only I can wrap myself around a few corners. So, anyone 
who
  has the urge to help me on getting those pieces of information straightend 
out, thanks
  to you, as it surely will help me crawling my way further on. :) Only hope my 
questions
  were clearly enough stated, that you will be able to give me the right push. 
:)

Reply via email to