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);
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);
If you want other programs to recognise what's on the clipboard, you need to use a recognised data format (e.g. plain text, or bitmap) string parameter, and to format the tree node into that format (e.g. if you choose text, you should pass a 'string' as the clipboard data, perhaps the TreeNode.Text value). See System.Windows.Forms.DataFormats for the different predefined types.
Notepad doesn't know anything about the Winforms TreeNode class. Use Clipboard.SetText() instead:
XAML:
C#: