I'm working for some time on manipulation of XML files in C # (I am a true beginner ).
I loaded an XML file from my computer in a treeview on my application interface, it'OK. I have also included a check box to be able to select data from this treeview. Am doing the same thing
with another XML file.
Now , If some nodes are checked
I wante to transfer objects between this two XML files using TreeView; in other way copy node from the first treeView the the second one (if is possible )
I try to do somthing like this
private void button4_Click(object sender, EventArgs e)
{
foreach (TreeNode node in treeView1.Nodes)
{
if (node.Checked)
{
TreeNodeCollection myTreeNodeCollection = treeView1.Nodes;
// Create an array of 'TreeNodes'.
TreeNode[] myTreeNodeArray = new TreeNode[treeView1.Nodes.Count];
// Copy the tree nodes to the 'myTreeNodeArray' array.
treeView1.Nodes.CopyTo(myTreeNodeArray, 0);
// Remove all the tree nodes from the 'myTreeViewBase' TreeView.
treeView1.Nodes.Clear();
// Add the 'myTreeNodeArray' to the 'myTreeViewCustom' TreeView.
treeView2.Nodes.AddRange(myTreeNodeArray);
}
}
}
The first problem is that check only the first parent , not any node
the second problem : the code copy all data and clear the treeview source.
My goal is to transfer data between the first XML file and the destination
So if you have an easier way to do this from a treeview, you can porposer me and I will be grateful
It's hard to be beginner