Hello,
Mainly I can't understand why I don't see node (Level 3) in case "wrong" in test example?
Cases wrong and right differ only of their order of nodes.
And one more question.
If i remove line 49
(ultraTreeNodeColumn1.DataType = typeof(string);)
in file Form1.Designer.cs
the tree looks like list
How it related with type of column?
I am using Infragistics2.Win.UltraWinTree.v10.3.dll (version 10.3.20103.1000)
Thank you
Roman
Hi Mike
1. I don't sure if I understand of you about null value. You can see in my test, Children never can be null.
I think first node should not determine the depth for full tree. It is some abstract hierarchy structure.
Else, the tree can be used just in some limited cases that I should keep in mind.
2. In case I use List<> instead of BindingList<>, behaviour is same.
But I don't understand why you worried about of type. It should work for any implementation IEnumerable<>. It is base abstract case.
3. If you don't like that Node inherits something, look another one:
public partial class Form1 : Form { public Form1() { InitializeComponent(); ultraTree1.ShowRootLines = true; RadioButtonCheckedChanged(radioButton1, EventArgs.Empty); } private readonly Node node0 = new Node("Node (no children)"); private readonly Node node1 = new Node("Node (level 1)", new Node("Node (level 2)", new Node("Node (level 3)"))); private void RadioButtonCheckedChanged(object sender, EventArgs e) { ultraTree1.DataMember = "Children"; ultraTree1.DataSource = radioButton1.Checked ? new Node("root", node0, node1) : new Node("root", node1, node0); ultraTree1.ExpandAll(ExpandAllType.Always); } } public class Node { public Node(string text, params Node[] children) { Text = text; this.children = children.ToList(); } public string Text { get; private set; } private readonly List<Node> children; public List<Node> Children { get { return children; } } }
public partial class Form1 : Form
{ public Form1() { InitializeComponent(); ultraTree1.ShowRootLines = true; RadioButtonCheckedChanged(radioButton1, EventArgs.Empty); }
private readonly Node node0 = new Node("Node (no children)");
private readonly Node node1 = new Node("Node (level 1)", new Node("Node (level 2)", new Node("Node (level 3)")));
private void RadioButtonCheckedChanged(object sender, EventArgs e) { ultraTree1.DataMember = "Children"; ultraTree1.DataSource = radioButton1.Checked ? new Node("root", node0, node1) : new Node("root", node1, node0); ultraTree1.ExpandAll(ExpandAllType.Always); } }
public class Node { public Node(string text, params Node[] children) { Text = text; this.children = children.ToList(); }
public string Text { get; private set; }
private readonly List<Node> children;
public List<Node> Children { get { return children; } } }
Notice that Node inherits nothing, it doesn't use BindingList and Children don't return null.
4. I tried Node to implement ICancelAddNew, but it is not used.
5. Unfortunatelly I can't see any manuals how I can use UltraTree with my business objects. I saw just examples with DataSets or with adding node items one to another.
6. You said nothing about the second question (about datatype) in original post.
I hope for help
Hi Roman,
The DotNet BindingManager determines the data structure using the first node. So in this case, when you click "Wrong", your first node has a single child node whicih has no children. Therefore the depth of the entire data structure is established at that point and the second and subsequent nodes will never show anything past the first child level.
You need to set this up in such a way that the Children always returns an empty collection, rather than returning null. Also, if the Children collection is empty, the BindingManager will not be able to determine the structure of the data on that level. The usual way it handles this is that it tries to add an item to the list and then cancel it. But in your case, that won't be possible since your data source doesn't implement ICancelAddNew or IEditableObject.
Also, the code as you have it here is very difficult to read and understand. I've never seen anyone use a BindingList of BindingLists with a Children property that returns itself. This is a very unusual scenario and I wouldn't be surprised if it caused a lot of unpredictable behaviors.
I tested version 12.2 and it shows the same