Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
290
Single ColumnSet Header per Cells/Rows
posted

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