How to select or find child node in a treeview

2019-08-17 06:35发布

I am able to find a parent node using the following code :

TreeNode node = TreeViewProducts.FindNode(nodeID);

Similarly if I want to find a child node in a treeview how do I do that.

Is there a way to find it as above rather than looping through all the nodes in the treeview

Thanks

1条回答
smile是对你的礼貌
2楼-- · 2019-08-17 07:16

You can use ChildNodes collection.

TreeNode node = TreeViewProducts.FindNode(nodeID);
foreach (var childNode in node.ChildNodes)
{

}
查看更多
登录 后发表回答