|
-
Jul 16th, 2007, 10:27 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] Iterate through treenodes
I'm struggling to work out how to iterate through treenodes. What I've done is programmatically created a TreeView, creating a (DatabaseName) header as follows:
Code:
trvDbNameNormal = Me.TreeView1.Nodes.Add("DatabaseName", "Common tables: " & Me.cmbDatabases.Text.ToUpper, 0, 0)
The children (table names) within this node are created by:
Code:
nodeTable = trvDbNameNormal.Nodes.Add(strTable, strTable, 1, 1)
What I want to do is iterate through these children to perform some SQL on the table names - but I can't figure out how to get the contents of these nodes.
-
Jul 16th, 2007, 10:48 AM
#2
Re: [2005] Iterate through treenodes
-
Jul 16th, 2007, 10:56 AM
#3
Thread Starter
Addicted Member
Re: [2005] Iterate through treenodes
Thanks - but all I keep getting is the Parent, not the Children. How do I get at the children?
-
Jul 16th, 2007, 11:01 AM
#4
Re: [2005] Iterate through treenodes
Did you try that code? It gets every single node in the TreeView.
-
Jul 17th, 2007, 03:09 AM
#5
Thread Starter
Addicted Member
Re: [2005] Iterate through treenodes
Sorry - yes - don't know what I did wrong. It does iterate through everything in the tree.
However, I realised what I was doing wrong on the way home last night! The simple solution was to declare the TreeNode I wanted to use as Private, and iterate through that node. Unfortunately, it shows the text "TreeNode: " and the treenode, but I can handle that.
Code:
For Each childNode As TreeNode In trvDbNameNormal.Nodes
MsgBox(childNode.ToString)
Next
Thanks for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|