删除顶级子节点时,Node.parentnode.nodes.remove(node)正在删除父节点。 [英] Node.parentnode.nodes.remove(node) is removing parent node when the top child node is removed.
问题描述
我正在尝试从RadTreeView父节点中删除子节点。只要它不是Parent下的顶级子节点,这个工作正常。
父母
> child1
> child2
> child3
> child4
如果我删除child2,3或4;有用。但是,如果我删除child1,则父项将与任何剩余的子节点一起删除。
我期望的行为是我应该能够删除任何子节点在任何顺序中,只有在删除最后剩余的子节点时才应删除父节点 - 但即使这样也是有争议的,因为如果我想在移除所有内容后向父节点添加更多子节点,该怎么办?
感谢您的帮助。
我是什么尝试过:
I'm trying to remove a child node from a RadTreeView Parent node. This is working fine as long as it is not the top child node under the Parent.
Parent
>child1
>child2
>child3
>child4
If I remove child2, 3 or 4; it works. But if I remove child1, the Parent is removed along with any remaining child nodes.
The behavior I expected is that I should be able to remove any of the child nodes in any order and the Parent node should be removed only when the last remaining child node is removed - but even that is debatable since what if I wanted to add more child nodes to the Parent node after removing everything?
Thanks for any help.
What I have tried:
Dim remove_node As RadTreeNode = rtvClientSpecs.FindNode(Function(x) x.Value = e.CommandArgument.ToString())
remove_node.ParentNode.Nodes.Remove(remove_node)
推荐答案
没关系,我想通了,谢谢。
我没有正确地聚合node.fullpath,因为我正在构建类集合以填充树视图。
Nevermind, I figured it out, thanks.
I wasn't properly aggregating the node.fullpath as I was building the class collection to populate the treeview.
这篇关于删除顶级子节点时,Node.parentnode.nodes.remove(node)正在删除父节点。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!