[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.
Re: [2005] Iterate through treenodes
Re: [2005] Iterate through treenodes
Thanks - but all I keep getting is the Parent, not the Children. How do I get at the children?
Re: [2005] Iterate through treenodes
Did you try that code? It gets every single node in the TreeView.
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. :thumb: