title: How do you cut, copy, and paste an extended Tree Node?
body: <p>I have a c# project using version 4.0 of the .net framework, and running on VS 2010. I have created a tree view populated with some extended tree nodes. I want the user to be able to copy, cut, and paste these nodes to the clipboard via a context menu or keyboard shortcuts (and not just drag-drop).</p>
  
  <p>The code runs fine when copying, but when I try to paste these nodes it throws this error:
  Unable to cast object of type 'System.IO.MemoryStream' to type 'Namespace Path.TreeNodeEx'.</p>
  
  <p>Here's my cut/copy/paste methods.</p>
  
  <pre><code>public void Copy()
  {
      Clipboard.SetData("Tree Node Ex", CurrentTreeNode.Clone());
  }
  
  
  public void Paste()
  {
      CurrentTreeNode.Nodes.Add((TreeNodeEx)Clipboard.GetData("Tree Node Ex"));
  }
  </code></pre>
  
  <p>I suspect the problem is something to do with serialization, but I've tried implement the ISeralizable Interface and the [Serializable] attribute to no avail.</p>
  
  <p>Any suggestions?</p>