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
215
Trying to duplicate a repeatable Node
posted

Kind of hard to explain, but I have a tree and tree represents tables in a relational database, basically the Dictionary.

Well if you click the parent node, it builds the children and grandchildren.  So now let's say I select TABLE1 as the parent node, I wil get a Child node called DEPENDS ON, this will drill down to other "parent" names, let's say TABLE2.  Now if I select TABLE2, it basically acts like if it was  a Parent and the same process repeats where I get another Child called DEPENDS ON.  Now this already works in C# controls.

Now for my problem trying to duplicate this with the UltraWinTree.  Only one ACTIVENODE can be enabled at a time, so when I click on TABLE2 in my example above, I get an error since I already have the ACTIVENODE of the first Parent.

I attached the code where I get the error when I click on the TABLE2 scenario, this always works the first time since I get my first ACTIVENODE which is the first Parent selected.

I get the error message that the Key already exist: Depends on

 

 

if (oNode.GetNodeCount(false) < 1)
                   {
                       ////////////////////////////////////////////////
                       /// Get Depends On only if it is a file
                       ////////////////////////////////////////////////
                       if (ParentIsFile && IsFile)  // we add the dependants and the depends on
                       {
                           ////////////////////////////////////////////////
                           /// Get Depends On
                           ////////////////////////////////////////////////
                          UltraTreeNode oDependsOn = new UltraTreeNode("Depends On");

                          //This is the code change to using the UltraTree control          

                          //This is where I get the error message that the Key already exist: Depends on
                          this.ultraTree1.ActiveNode.Nodes.Add(oDependsOn);

                            //Old code from Native Tree control
                           //this.ultraTree1.SelectedNodes.Nodes.Add(oDependsOn);

                           foreach (DataRow dr_GetTableDefSql in dt_GetTableDefSql.Rows)
                           {
                               string temp = dr_GetTableDefSql["ColumnName"].ToString();

                               if (temp.ToLower().EndsWith("id"))
                               {
                                   string strRelative = temp.Trim().Substring(0, temp.Trim().Length - 2);
                                   if (strRelative.ToLower() == "user")
                                       strRelative = "SyStaff";

                                   dv_SyDictTables.RowFilter = "Tablename = '" + strRelative.Trim() + "'";
                                   if (dv_SyDictTables.Count > 0)
                                   {
                                       if (strRelative != TableName)
                                       {
                                           UltraTreeNode oChild = new UltraTreeNode();
                                           oChild = new UltraTreeNode(strRelative);
                                           oDependsOn.Nodes.Add(oChild);
                                       }
                                   }
                               }
                           }