Can someone send me a small example with 3 parents levels that has 3 child to each parent. First time using a treeview. I want to build the tree dynamically in code. This is would be helpful.
parent A
child A.1
child A.2
child. A.3
parent B
child B.1
child B.2
child. B.3
child C.1
child C.2
child. C.3
foreach( var gRow in Group) { if (!ultraTree1.Nodes.Contains(gRow.PARENT)) { UltraTreeNode GetUltraTreeNode = new UltraTreeNode(bLine.gRow.ToString(), bLine.INDENT.ToString()); if (!this.ultraTree1.Nodes.Contains(GetUltraTreeNode.Key)) { this.ultraTree1.Nodes.Add(GetUltraTreeNode); //I keep getting key already exist. I am not understanding why if I have logic thats said not exist } } }
KeithDudley said:I keep getting key already exist. I am not understanding why if I have logic thats said not exist
For one thing, the Contains method doesn't take a key, it takes in a node object. So it will always return false if you pass in a string.You should be using the Exists method if you want to check for the existance of a key.
Also, node keys have to be unique to the entire tree, not just unique to the collection they are in. So even if the Exists method returns false, that only means that a node with that key does not exist in that collection. It does not account for every nodes collection in the entire tree.
Ok I am not for sure, why the tree is not showing the nodes, I have add the nodes usinfg the logic below.
foreach
(var gRowin Group){
if (!ultraTree1.Nodes.Exists(gRowin .PARENT.ToString()))
{
UltraTreeNode GetUltraTreeNode = new UltraTreeNode(gRowin .PARENT.ToString());
if (!this.ultraTree1.Nodes.Exists(GetUltraTreeNode.Key))
this.ultraTree1.Nodes.Add(GetUltraTreeNode.Key);
}
Ok I have the parent node working. I have to close down visual studio and open it back up, and every thing started working. Which was really weird.
Next question, how to add a record to a UltraTree
Hi Keith,
KeithDudley said:Next question, how to add a record to a UltraTree
I'm afraid you lost me. I do not understand what you are asking. What do you mean by "record?" Are you making some distinction between a "record" and a node? You seem to have already figured out how to add nodes to the tree. And I don't have any idea what you mean by "record". The tree doesn't have any ability to contain anything other than nodes.
So you are asking how to add columns and child nodes to the tree in code? I'm not sure how I was supposed to gather all that from the word "record", but if that's what you want, I posted some sample code for this just recently:
UltraTree - Infragistics Community
I am looking to put a multi-column entry in a node, and im looking to display like a grid per node if that makes any sense. I want to build this in code. It works if I set the datasource from the designer. But the level of indent or childs I have to build would be better if I build the tree in code.
Review File Attachment. Can you send me a small example to help me this in code, I am going to have multiple levels of childs bands or bands
I will send you a print screen of assign ultra tree datasource to show you a record, I am not for sure of the term. To me its a record. give me one second.brb.