How to debug TreeNodeCollection
Question
The code in question:
TreeNode categoryNode = categories.Nodes[category]; //BREAKPOINT HERE
categoryNode.Add("New Node")
My question is less about the code itself (it all makes sense to me), so much as the debugger. When at the break point I want to look at the TreeNode
s in categories.Nodes
, but categories.Nodes
is a TreeNodeCollection
and I can't find the underlying list, array, or whatever is actually used under TreeNodeCollection
's hood.
How do I navigate the TreeNodeCollection
so that I can find the actual list in question?
Solution
Look at individual nodes in the collection with categoryNode[0], changing the index. Or drill down into the private owner property. Its children field gives you a list of all the nodes. Or if Linq is in scope, you can type
categoryNode.OfType<TreeNode>(), results
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow