C# Treeview checking if node exists

前端 未结 8 566
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-23 12:42

I\'m trying to populate a treeview from an XmlDocument. The Root of the tree is set as \'Scripts\' and from the root the next level should be \'Departments\' which is within the

相关标签:
8条回答
  • 2021-01-23 13:24

    Depending upon the size of your XML file, you could consider using an associated List for fast lookup. As you add each node to the TreeView also add it to the List.

    0 讨论(0)
  • 2021-01-23 13:28

    It depends on the structure of your input. Since you don't show how exactly you add your subnodes I can only point you towards either the Contains or the ContainsKey method of the Nodes property, either of the treeView1 itself, or of any subnodes you add. You should use an overload of the Add method to specify a key name to simplify lookup.

    0 讨论(0)
提交回复
热议问题