I am trying to copy the selected treeview node to the clip board so I can paste it in notepad. Here is my code but it doesn't work.
TreeNode selNode = (TreeNode)this.treeView1.SelectedNode;
Clipboard.SetData("TreeNode", selNode);
Notepad doesn't know anything about the Winforms TreeNode class. Use Clipboard.SetText() instead:
private void treeView1_KeyDown(object sender, KeyEventArgs e) {
if (e.KeyData == (Keys.Control | Keys.C)) {
if (treeView1.SelectedNode != null) {
Clipboard.SetText(treeView1.SelectedNode.Text);
}
e.SuppressKeyPress = true;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With