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
1370
Cloning a node from Treeview databound
posted

Hi,

I'd like to copy a node from TreeView to another Treeview but I want to keep each Cells of the nodes databound from DataTable.

The Clone methode doesn't clone cells.

From a node with cells, the result is a node with only a single value ...

Code :

trvProjects.DataSource = dsBudgetMap;
trvProjects.DataMember = "BUDGET";

foreach (UltraTreeNode tnTas in tnPro.Nodes)
     trvTaskLate.Nodes.Add(tnTas.Clone()); 

  • 469350
    Offline posted

    I'm not sure exactly what you are trying to do. But it makes sense that the underlying data from the data source is not cloned. It's probably not cloneable.

    Is the second tree bound? You might want to simply bind the second tree to a data source with the same structure as the first tree, and then you can add nodes to the second tree by copying the data and adding a new row to the data source.

    Otherwise, your second tree will need to have a ColumnSet (or sets) defined that match the structure of the first tree's columns and then you will have to loop through the cells and copy the value of each cell.