And if I want to bind a one to a data base, it seem to build the structure without my interference, how can I control it?
Here is a simple example of how to populate the control with 3 levels of nodes:
// Use the NodeLevelOverrides collection to assign images based on the level// at which the node resides...level zero represents the root Nodes collection,// and each subsequent level reflects how "deep" into the hierarchy the node is.this.ultraTree1.NodeLevelOverrides[0].NodeAppearance.Image = rootNodeImage;this.ultraTree1.NodeLevelOverrides[1].NodeAppearance.Image = childNodeImage;this.ultraTree1.NodeLevelOverrides[2].NodeAppearance.Image = grandChildNodeImage;
// Switch off painting temporarily while the tree is populatedthis.ultraTree1.BeginUpdate();
for ( int i = 0; i < 10; i ++ ){ // Create a node and add it to the control's Nodes collection UltraTreeNode rootNode = new UltraTreeNode( null, string.Format("Node {0}", i) ); this.ultraTree1.Nodes.Add( rootNode );
for ( int j = 0; j < 10; j ++ ) { // Add a node to the root node's Nodes collection UltraTreeNode childNode = rootNode.Nodes.Add( null, string.Format("Node {0}.{1}", i, j) );
for ( int k = 0; k < 10; k ++ ) { // Add a node to the child node's Nodes collection UltraTreeNode grandChildNode = childNode.Nodes.Add( null, string.Format("Node {0}.{1}.{2}", i, j, k) ); } }}
// Resume paintingthis.ultraTree1.EndUpdate();
Regarding controlling the structure of a data bound tree: This can be accomplished using the ColumnSetGenerated event, and the properties of the UltraTreeColumnSet and UltraTreeNodeColumn classes. An example of how to use these classes is available in the 'UltraTree DataBinding' sample that ships with the product.