如何通过单击或选择节点来克隆整个节点及其子节点?假设通过单击节点,其子项也被选中。然后就不需要检查它们是否已被选中。
答案 0 :(得分:1)
//this example copies the selectednode from TreeViewTemplates to TreeForCopiedItem after you click a node.
//set the .afterselect-event of the treeview with the code below
//shouldn't be to hard to convert to C#
// Update : .clone returns an object, so use Ctype for explicit conversion
Private Sub TreeViewTemplates_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeViewTemplates.AfterSelect
TreeForCopiedItem.Nodes.Clear()
Dim copiedNode As TreeNode = CType(TreeViewTemplates.SelectedNode.Clone, TreeNode)
TreeForCopiedItem.Nodes.Add(copiedNode)
End Sub