Looping Through All Nodes In A VB.NET Tree View And Highlighting Them.
From: Michael The Red (michaelthered_at_hotmail.com)
Date: 07/06/04
- Next message: Parthiv Joshi: "How to make a week view and day view calendar just like month view calendar in .NET ?"
- Previous message: Stephen Martinelli: "touchscreen keyboard"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Looping Through All Nodes In A VB.NET Tree View And Highlighting Them."
- Reply: Herfried K. Wagner [MVP]: "Re: Looping Through All Nodes In A VB.NET Tree View And Highlighting Them."
- Reply: Michael The Red: "Re: Looping Through All Nodes In A VB.NET Tree View And Highlighting Them."
- Messages sorted by: [ date ] [ thread ]
Date: 5 Jul 2004 21:31:10 -0700
I am attempting to loop through all the nodes in a tree view and
highlight them as the loop is active. All nodes would include to
children nodes of parent nodes and so on.
I have a function in my application that builds a tree view. It
populates the tree view with parent nodes. The parent nodes are the
drives on my pc. When the user selects the node, I have a function
that takes the tag of the node and passes it to the Directory method.
A node is then created under the selected node with folder names.
I now have a tree view with parent and children nodes. Now, I would
like to loop through all the nodes in the tree view as it is now. For
example…the Root Parent nodes are drives A, C, D, E, and F. When the
user selects F, then children nodes are added…like…Movie Folder, Doc
Folder, File Folder….whatever folders that are under F. I would like
to loop through all the nodes and highlight them as the loop goes
along.
I figured I could get a node count in the beginning and simply
interate through the node index. In my example, the node count was
something like 15. so I figured I could just do something like this…
Dim nodeCount As Intger = TreeView.GetNodeCount(True)
Dim inc As Integer = 0
Dim nodeTag As String
Do While Not(inc > nodeCount)
nodeTag = TreeView.Nodes.Item(inc).Tag
‘HIGHLIGHT THIS NODE AND DO SOMETHING WITH NODE
inc = inc + 1
Loop
The problem I am seeing is that the node count is 15, because I added
nodes to the tree from a nodes selection event, but when I go to index
6, I get a message like "Index is out of range." I figured it should
be in range because the nodes exist.
Do I have to do something special to add the nodes to the nodes
collection? Aren't the nodes automatically added to the node
collections when they are created? Why would child nodes be out of
range?
I don't know how I can simply loop through all the nodes, could
someone please, please, please help me out with this?
Thank you all.
- Next message: Parthiv Joshi: "How to make a week view and day view calendar just like month view calendar in .NET ?"
- Previous message: Stephen Martinelli: "touchscreen keyboard"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Looping Through All Nodes In A VB.NET Tree View And Highlighting Them."
- Reply: Herfried K. Wagner [MVP]: "Re: Looping Through All Nodes In A VB.NET Tree View And Highlighting Them."
- Reply: Michael The Red: "Re: Looping Through All Nodes In A VB.NET Tree View And Highlighting Them."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|