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
1785
Bound UltraTree order of column sets
posted

I have a grid-style UltraTree which I'm binding to a DataSet.  The DataSet has four DataTables, added to the DataSet in the following order:
     Basic Information
     Designators
     Categories
     Country Roles

Four column sets are generated, four root-level nodes are added to the tree and all of the rows in each table are shown as child nodes.  Everything is working just fine EXCEPT... the order of the root-level nodes does NOT match the order of the tables in the DataSet.  They are being displayed:
     Country Roles
     Basic Information
     Designators
     Categories

So as a test, I changed the order to Basic Information --- Country Roles --- Designators --- Categories, and the root-level nodes appeared the same as shown above.  It seems like it doesn't matter what order the tables appear in the DataSet, the Country Roles table is always the first root-level node.

Thoughts?  Any way I can tell the tree exactly what order to show the tables in?  I really, really need Basic Information to be the first node.  I can live with the other three tables being in any order.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    The default order is determine by the BindingManager in DotNet. It tends to be pretty arbitrary about the order of sibling bands, though - it does not appear to take the order of the tables in the DataSet into account.

    The only way to control the order is to make the nodes unbound. This is pretty easy to do - just don't bind the tree control itself. Instead, Add a root-level node to the tree using the tree.Nodes.Add method for each of your tables. Then you bind the child nodes collections of those root-level nodes to the table(s) you want.


            private void Form1_Load(object sender, EventArgs e)
            {
                DataSet ds = new DataSet();
                DataTable dtA = new DataTable("A");
                this.InitializeTable(dtA);
                DataTable dtB = new DataTable("B");
                this.InitializeTable(dtB);
                DataTable dtC = new DataTable("C");
                this.InitializeTable(dtC);
                DataTable dtD = new DataTable("D");
                this.InitializeTable(dtD);

                ds.Tables.Add(dtA);
                ds.Tables.Add(dtB);
                ds.Tables.Add(dtC);
                ds.Tables.Add(dtD);

                // If I bind the tree, the tables show up in reverse order (D, C, B, A).
                // So don't bind the tree.
                //this.ultraTree1.SetDataBinding(ds, null);

                UltraTreeNode nodeA = this.ultraTree1.Nodes.Add("A", "A");
                nodeA.Nodes.SetDataBinding(ds, "A");
                UltraTreeNode nodeB = this.ultraTree1.Nodes.Add("B", "B");
                nodeB.Nodes.SetDataBinding(ds, "B");
                UltraTreeNode nodeC = this.ultraTree1.Nodes.Add("C", "C");
                nodeC.Nodes.SetDataBinding(ds, "C");
                UltraTreeNode nodeD = this.ultraTree1.Nodes.Add("D", "D");
                nodeD.Nodes.SetDataBinding(ds, "D");
            }

            private void InitializeTable(DataTable dt)
            {
                dt.Columns.Add("Column 0");
                dt.Rows.Add();
            }

     

Children