日期:2014-05-18 浏览次数:21398 次
TreeNode td = (TreeNode)this.treeView1.SelectedNode.Clone(); this.treeView2.SelectedNode.Nodes.Add(td);
------解决方案--------------------
TreeNode currentNode = null; TreeNode copyNode = null; bool canCopy = false; private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { currentNode = e.Node; } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys)Shortcut.CtrlC) { if (treeView1.Focused) { copyNode = currentNode.Clone() as TreeNode; canCopy = true; } } if (keyData == (Keys)Shortcut.CtrlV) { if (treeView1.Focused && canCopy) { currentNode.Nodes.Add(copyNode); canCopy = false; } } return base.ProcessCmdKey(ref msg, keyData); }