如何在UltraTreeNode集合中添加自定义属性(Infragistics UltraTree Control)

时间:2018-11-28 23:05:18

标签: c# winforms infragistics ultratree

如何在UltraTreeNode集合中添加自定义属性?使用UltraTree Infragistics控件12.x版本。

例如:

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);

1 个答案:

答案 0 :(得分:0)

正如斯图亚德所写,您可以像这样继承UltraTreeNode

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

    public string SomeOtherCustomProperty { get; set; }
}

然后您可以像这样使用CustomUltraTreeNode代替UltraTreeNode

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);