获取TreeView中的所有最后一个节点. [英] Get all the last node in a TreeView.
本文介绍了获取TreeView中的所有最后一个节点.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好;
我有一个有很多节点的树视图,有没有办法让我得到树所具有的每个节点中的所有最后一个节点?
谢谢.
Hi Everyone;
I have a treeview that has a lot of nodes, Is there a way I can get all the last nodes in each node that the tree has?
Thanks.
推荐答案
我知道的唯一方法是从TreeView
本身的Nodes
集合开始,然后递归地访问,或者以其他方式访问其Nodes
集合.依此类推........然后使用Nodes[Nodes.Count - 1]
来获取每个节点的最后一个节点.
The only way I know is to start with theNodes
collection of theTreeView
itself and then recursively or otherwise visit itsNodes
collection and so on..... then useNodes[Nodes.Count - 1]
to get the last node for each one.
可以给我一个例子吗?我尝试了这段代码,但没有返回最后一个节点.
Can you please give me an example? I tried this code but it didn''t return the last node.
ArrayList ae = new ArrayList();
for (int iCount = 0; iCount < mytreev.nodes.Count; iCount++)
{
ae.Add(nodes[nodes.count-1].LastNode.Text)
}
看看 ^ ]线程.
第四项有一个代码示例(在VB.net中,但应该足够容易理解)
顺便说一句在您的代码中:
Take a look at this[^] thread.
The 4th entry has a code example (it''s in VB.net but should be easy enough to understand)
Incidentally in your code:
ae.Add(nodes[nodes.count-1].LastNode.Text)
我不知道您从哪里获得LastNode
属性.据我所知,没有这样的财产.应该是:
I don''t know where you have got the LastNode
property from. As far as I know, there is no such property. It should be:
ae.Add(nodes[nodes.count-1].Text)
如果您将上面链接中的方法与从此处 [ ^ ],您应该能够解决问题.
If you combine the method from the link above with the example of iterating the Nodes of a TreeView from here[^] on MSDN, you should be able to work out a solution.
这篇关于获取TreeView中的所有最后一个节点.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文