Hi thx Richard for that info Not familiar with recursion, but now you've helped me improve my understanding of treeviews. I did circumvent the problem by updating node properties as they are created. I can post that code if it might help others. demac ;)
User 9285131
Posts
-
Treeview iteration -
Treeview iterationI have a tree created at design time with 3 root nodes and 3 levels 3x3x3 =39 nodes as the default.
The nodes can be dynamically recreated.
When I cleared the nodes then recreated them, I tried looping through to add properties to the nodes of each level including their relevant context menu name.
Private Sub RedoTree\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RedoTree.Click treeLoad() treeExecutive.ExpandAll() restoreTP() treeExecutive.Nodes(0).EnsureVisible() End Sub Sub restoreTP() ' renew treenode properties Dim s As String, l As Short treeExecutive.Update() For Each treenode In treeExecutive.Nodes s = treenode.Name l = Len(s) treenode.ForeColor = Color.GhostWhite If treenode.Text <> s Then treenode.ForeColor = Color.Black Select Case l Case 1 treenode.NodeFont = New Font("Arial Rounded MT Bold", 10.8) treenode.ContextMenuStrip = CMSRoot Case 2 treenode.NodeFont = New Font("Arial", 10.2) treenode.ContextMenuStrip = CMSTree Case Else treenode.NodeFont = New Font("Arial Narrow", 9) treenode.ContextMenuStrip = CMSTree End Select Next End Sub
The root nodes are number 1-3, then 11,12,13 .... 111,112,113 Total is 39 nodes
ONLY THE ROOT NODES ARE RECOGNISED AND DEALT WITH.
All the child nodes are ignored as if they don't exist
Am bogged down on this and would appreciate any help :confused:
Demac
-
Treeview iterationI have a tree created at design time with 3 root nodes and 3 levels 3x3x3 =39 nodes as the default. The nodes can be dynamically recreated. When I cleared the nodes then recreated them, I tried looping through to add properties to the nodes of each level including their relevant context menu name.
Private Sub RedoTree\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RedoTree.Click treeLoad() treeExecutive.ExpandAll() restoreTP() treeExecutive.Nodes(0).EnsureVisible() End Sub Sub restoreTP() ' renew treenode properties Dim s As String, l As Short treeExecutive.Update() For Each treenode In treeExecutive.Nodes s = treenode.Name l = Len(s) treenode.ForeColor = Color.GhostWhite If treenode.Text <> s Then treenode.ForeColor = Color.Black Select Case l Case 1 treenode.NodeFont = New Font("Arial Rounded MT Bold", 10.8) treenode.ContextMenuStrip = CMSRoot Case 2 treenode.NodeFont = New Font("Arial", 10.2) treenode.ContextMenuStrip = CMSTree Case Else treenode.NodeFont = New Font("Arial Narrow", 9) treenode.ContextMenuStrip = CMSTree End Select Next End Sub
The root nodes are number 1-3, then 11,12,13 .... 111,112,113 Total is 39 nodes
ONLY THE ROOT NODES ARE RECOGNISED AND DEALT WITH.
All the child nodes are ignored as if they don't exist
Am bogged down on this and would appreciate any help :confused:
demac