How do you convert this sample code to ONLY display one set of ColumnSet header per cells/rows. Sample code came from NETAdvantage For Windows Forms sample projects.
private void PopulateTreeWithAnimalData() { // Load the XML document containing the data XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(DataHelper.DataPath + @"\Animals.xml");
// Get the root element XmlElement rootElement = xmlDoc.DocumentElement;
// Set the ViewStyle of the this.treeAnimals to FreeForm this.treeAnimals.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.FreeForm;
// Clear any existing nodes in the tree this.treeAnimals.Nodes.Clear();
// Add a Root node to the tree representing the root // Element in the XML UltraTreeNode rootNode = this.treeAnimals.Nodes.Add(null, rootElement.Name);
// Loop through the child nodes of the root element foreach (XmlElement categoryElement in rootElement.ChildNodes) { // Get the category attribute on each child node string category = categoryElement.GetAttribute("category");
// Create a category node in the tree to represent // the category of the xml node UltraTreeNode categoryNode = rootNode.Nodes.Add(null, category);
// Loop through the child elements of the Category // node. foreach (XmlElement animalElement in categoryElement.ChildNodes) { // Create a ColumnSet based on the Attributes of this element // Each attribute will represent a column. UltraTreeColumnSet columnSet = new UltraTreeColumnSet();
// The ColumnSet key will be the animal type. columnSet.Key = animalElement.GetAttribute("type");
// Add the new ColumnSet into the ColumnSets collection this.treeAnimals.ColumnSettings.ColumnSets.Add(columnSet);
// Create a tree node to represent the XML animal node UltraTreeNode animalNode = categoryNode.Nodes.Add(null, animalElement.Name);
// Assign the newly created ColumnSet to this node. animalNode.Override.ColumnSet = columnSet;
// Loop through the attributes of the animal xml // node. foreach (XmlAttribute attribute in animalElement.Attributes) { //For each attribute, create a Column in the // ColumnSet. UltraTreeNodeColumn column = columnSet.Columns.Add(attribute.Name);
// Populate the tree node's cell with the // appropriate value. animalNode.Cells[attribute.Name].Value = attribute.Value;
// AutoResize the column so it fits the text column.PerformAutoResize(Infragistics.Win.UltraWinTree.ColumnAutoSizeMode.AllNodesWithDescendants); } } }
// Expand all the nodes this.treeAnimals.ExpandAll(); }
May I get help on the above post?
Thanks,
JCT
Hello Jean Claude,
Changing the above code to display the same set of columns for each node does not make sense because the data being loaded into the tree is heterogeneous. There are other projects in our samples which show the same set of columns on each node at a specified level in the tree.
Hi,
It's possible to get a "search free" link to one of the sample projects?
Thanks and Greatings: Rudy
Hello,
Our Windows Forms samples need to be downloaded and installed before they can be executed.