如何将树视图的一个实例的节点添加到同一树视图的另一个实例
如何将节点填充到 newtreeview1 (另一个 treeview1 的实例)中?添加到“newtreeview1”的节点应该在 Treeview1 的第一个实例中可用?
例如;如果treeview1包含
|-- Node1
|-- Node2
| -- Node3
|-- Node4
newtreeview1也应该有上述节点。
How to populate the nodes into the newtreeview1 which is the instance of the another treeview1 ? The nodes which is added to the "newtreeview1" should be available in the first instance of the treeview1?
for example; if the treeview1 contains
|-- Node1
|-- Node2
| -- Node3
|-- Node4
the newtreeview1 should also have the above nodes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以通过克隆每个节点来完成此操作
像这样
并调用该函数
you can do this by cloning each node
like this
and call the function
您需要复制节点。类似于:
根据您想要的,您需要选择一个 Add 方法的重载,其中包括您要复制的所有数据(密钥、文本和/或图像)。只是不要直接添加节点,而是添加它们的组成部分。
You need to copy the nodes. Something like:
Depending on what you want, you need to pick an overload of the Add method that includes all the data you want to copy (key, text, and/or images). Just don't add the nodes directly, but instead their constituent parts.
您可以尝试下面链接中给出的方法并序列化您的树内容。然后根据序列化的内容构造一个新的树视图。我知道这是一种冗长的方法,但这可以保证将所有层次结构数据正确添加到第二个树视图中。
从树视图中保存节点
You could try the approach given in this below link and serialize your tree contents. Then construct a new treeview based on the serialized contents. A big of a long-winded approach I know but this is guaranteed to add all the hierarchial data properly into the second treeview.
Save nodes from a treeview
您只需复制 TreeView1 实例并添加其他节点即可。
与下图相同
You can just copy the TreeView1 instance and add additional nodes.
Same thing as shown below