Thanks, both of you.
One more question:
Is there a way to determine which Depth or Level a Child is at? Like if you
have a tree looking like this:
My
Name
Is
David
What
Is
yours
With the .Text property you get the words, but If I wanted to know that
"David" is at level 4, and "yours" at level 3. Maybe I am overlooking
something, but I can't seem to find anything.
I thought I could have used the .Indent property, with a line in your sub
Aaron, like:
Speak Child.Indent
, but that throws an error at me, telling the property is not supported.
Wonder where I got lost this time. :)
----- Original Message -----
From: "Aaron Smith" <[email protected]>
To: <[email protected]>
Sent: Monday, August 13, 2012 6:37 PM
Subject: Re: TreeView - please help
Here's the routine that the TreeView app uses when you do a find:
Sub FindNode(str, node)
If Not node Is Nothing Then
If InStr(LCase(node.Text), LCase(str)) > 0 Then
Set searchResults(searchResults.Count + 1) = node
End If
If node.Children.Count > 0 Then
Dim child
For Each child In node.Children
FindNode str, child
Next
End If
End If
End Sub
This searches through all of the nodes in the tree, and stores matches
in a Dictionary object.
It's called with something like:
FindNode "searchString", treeview.Root
Aaron
On 8/13/2012 12:28 PM, Stephen Clower wrote:
David,
If you're just wanting to iterate through a tree, you don't have to
expand or collapse items. Just go through the entire collection
(starting at the root element), and process each branch recursively. The
WE object model should give you all you need for traversing treeviews.
Please let us know if it doesn't.
Regards,
Steve
On 8/13/2012 11:59 AM, David wrote:
Thanks.
Got a bit confused by the text in the Reference Manual.
My idea is to "read" or retrieve the whole information from the tree
structure itself. That is the full set of text (labels) for the entries
of the tree. My sub was just set up, to at least get in touch with the
treeview.
Am I on the right track, when asuming that I will have to retrieve a
TreeviewItem from each entry in the TreeViewItems list, and then go from
there? And will I have to "manually" let the app expand every branch of
the treeview, or is there a more direct way of getting to the individual
labels?
Hope my questions make sense. So, I am not trying to construct a
treeview, but to retrieve information from an already existing treeview,
for further handling.
Thanks again,
----- Original Message ----- From: "Stephen Clower" <[email protected]>
To: <[email protected]>
Sent: Monday, August 13, 2012 2:09 PM
Subject: Re: TreeView - please help
David,
Are you wanting to obtain all tree view items? If so, try this:
Sub TheTreeview()
Dim Win: Set Win = FocusedWindow
If Win.Type <>WtTreeView Then Exit Sub
' Apparently we are in a TreeView:
Speak Win.Type
Speak "You are now in a treeview."
Dim TView: Set TView = Win.Control ' Note that this gives you the
treeview control directly. You do not need to explicitly request a
tree view.
' TreeViewItems was never defined, so I assume you meant to get the
number of items in the tree's top level. In that case:
speak TView.TopLevel.Count
End Sub 'TheTreeview.
Regards,
Steve
On 8/12/2012 8:16 PM, David wrote:
I have the following sub:
Sub TheTreeview()
Dim Win: Set Win = FocusedWindow
If Win.Type <>WtTreeView Then Exit Sub
' Apparently we are in a TreeView:
Speak Win.Type
Speak "You are now in a treeview."
Dim Ctrl: Set Ctrl = Win.Control
Dim TView: Set TView = Ctrl.TreeView
speak TreeViewItems.Count
End Sub 'TheTreeview.
I can place my cursor on anything else but a treview, and the sub
will simply exit. So far, things are alright.
When I put my cursor on a treview, and run this sub, it sure speaks
two lines of info:
22
You are now in a treeview.
Just what I expected it to.
But then it throws an error on me:
Object doesn't support this property or method: 'Ctrl.TreeView'
A bit confused. Likely I am missing something, but can't figure
exactly what. In the documentation of WE, it states under TreeView:
Usage
Use a
TreeView
object to retrieve information regarding a tree view control. A
TreeView
object can be obtained from a
Window
object's
Control
method when the
Window
object's
Type
is
wtTreeView
In my sub, I set an object (Win) from the FocusedWindow. Then another
object (Ctrl) from that Window object's Control. Isn't that what the
documentation claims to be the way to go? And from here, I should
have been able to retrieve the TreeView object. What am I missing?
Thanks for any guidance.
--
Stephen Clower
Product support specialist & App Development
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.