I’m writing a bit of code that I want to populate a TreeView, which it does quite successfully, but I also want to put a Dictionary in the Tag of each Level 1 child node. Once the Tag has been set to the Dictionary, is there any way I can modify the dictionary, without redeclaring the Tag.
For Each verse In Verses
Dim _verse = verse.ToString.Trim
Dim _node As TreeNode = New TreeNode(_verse.Split(vbNewLine).First & "...")
_node.ToolTipText = _verse
_node.Tag = New Dictionary(Of String, Object)
Node.Nodes.Add(_node)
Next
You can later just cast the tag of the not to
Dictionary(Of String, Object)and then manipulate the dictionary as usual.For example, assuming that
currentNodeis the node of interest, you can have something like the following.