1

How can I add a custom property in UltraTreeNode collection? using UltraTree Infragistics control 12.x version.

For example:

UltraTree MyUltraTree = new UltraTree();
UltraTreeNode MyNode =  new UltraTreeNode();
MyNode.Text = "Caption of My Node";
MyNode.MyCustomProperty = "This is custom property want to Add in Node Collection";
MyUltraTree.Nodes.Add(MyNode);
Haseeb
  • 746
  • 7
  • 22
  • 1
    It's [not sealed](http://help.infragistics.com/Help/Doc/WinForms/2012.1/CLR2.0/html/Infragistics2.Win.UltraWinTree.v12.1~Infragistics.Win.UltraWinTree.UltraTreeNode.html), so you can subclass it. Or you could just use the `Tag` property? – stuartd Nov 28 '18 at 23:12
  • Right but I need to add many properties. multi vales. If i use tag property it will be hard to handle. However you are right Tag property is ultimately last solution – Haseeb Nov 28 '18 at 23:18

1 Answers1

0

As stuard wrote you can inherit UltraTreeNode like this:

public class CustomUltraTreeNode: UltraTreeNode
{
    public string MyCustomPorperty { get; set; }

    public string SomeOtherCustomProperty { get; set; }
}

Then you can use CustomUltraTreeNode instead of UltraTreeNode like this:

UltraTree MyUltraTree = new UltraTree();
CustomUltraTreeNode MyNode = new CustomUltraTreeNode();
MyNode.Text = "Caption of My Node";
MyNode.MyCustomPorperty = "This is custom property want to Add in Node Collection";
MyNode.SomeOtherCustomProperty = "This is some other custom property";
MyUltraTree.Nodes.Add(MyNode);
wnvko
  • 1,985
  • 1
  • 14
  • 18