Monday, December 7, 2009

Microsoft Treeview Nodes.AddRange

Have you ever tried to add nodes in the Microsoft Treeview using the AddRange method, it is not fun to do that as you cannot create a new TreeNodeCollection.After doing quite a bit of research we found a way to do this.Here is the trick.

vb.net sample code:

Dim ndc as new list(of TreeNode)

For i as Integer = 0 to 10 step 1
Dim nd as new TreeNode
nd.text = "node " + i.tostring
ndc.add(nd)
Next 1

Me.treeview1.Nodes.AddRange(ndc.ToArray)

No comments:

Post a Comment