treeview - Adding childs to a treenode dynamically in c# -


I want to dynamically add a node to my child in the root node in my TreeView . I have a string of some names like {"john", "sean", "edwin"} array but it can be big or small.

I have this kind of root:

  // main node (root) string newNodeText = "family1" turn node main node = new triode (newnode text, New Triode [] How to Add dynamic children from here ??!? * /}); MainNode.Name = "root"; MainNode.Tag = "Family1;   

And I'm trying to do this with an array of names of my children like this:

  foreach ( Xml in string item) .GetTestNames ()) //xml.GetTestNames childs {stringNode child = new triode (); child.Name = item; child.Text = item; child.Tag = "child"; child.NodeFont = new Font (listView1.Font, FontStyle.Regular);}   

But obviously it is not working. Indication: I have the number of elements in my children's array !!!! >

Edit 1:

I'm trying to: TreeNew TreeNode [xmlGetestasNumber ()]; INTI = 0; FRECH (string item xml.GetTestNames ()) {textbox1.AppendText (item); tree [I] .name = object; tree [i]. Text = object; tree [i] .Tag = "hair", tree [i] .NodeFont = new font (listView1.Font, FontStyle.Regular); i ++ ;} // main node (root) string newNodeText = xml.FileInfo ("fileDeviceName") + "[" + filename + "]"; // The name of the device in the text of the root node will also be TreeNode mainNode = New TreeNode (newnode text, tree); MainNode.Name = "root"; MainNode.Tag = pathToFile; // See the main node and his child tree View tree view. Node.ad-range (new tree node [] {main node});

But this will not add anything to my tree view.

You need to add a child node to parents, here's an example:

  triview myTreeView = new tree view (); MyTreeView.Nodes.Clear (); Foreach (string parentText in xml.parent) {TreeNode parent = new TreeNode (); mother-father. Text = original text; MyTreeView.Nodes.Add (treeNodeDivisions); Foreign currency (string child text in xml.child) {tree_node = new triode (); Child.Text = childText; Parent.Nodes.Add (child); }}    

Comments