I have my own class MyTreeNode derived from TreeNode:
public class MyTreeNode : System.Windows.Forms.TreeNode
{
[Localizable(true)]
public bool Foo { get; set; }
}
I try to clone the node:
MyTreeNode myTreeNode = new MyTreeNode();
myTreeNode.Foo = foo;
//
//And here is the problem, all fields have been copied to the new node but Foo
//
MyTreeNode newNode = (MyTreeNode)myTreeNode.Clone();
In result, newNode has empty Foo field. How can I fix this ?
If you want
Footo be copied as well when callingClone(), you’ll need to override theClone()method and add the logic to do so.All you need to do is add this to your
MyTreeNodeclass: