How can i create multiple treeview and add a Root node to that specific treeview and show those treeviews to a control?

242 views Asked by At

Currently I can create multiple treeview using a for loop and show those tree view to tabpage but my root node doesnt show. This is what I have so far a

 private void button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < ThreatEvaluationInstances.Count; i++)
        {
            string a = i.ToString();
            TreeView tv  = new TreeView();
            tv.Name = "tv" + i;
            tv .Location = new Point(8, i* 100);
            tv.Size = new Size(841, 125);
            TreeNode root = new TreeNode(ThreatEvaluationInstances.ElementAt(i).Threat1 + " (" + ThreatEvaluationInstances.ElementAt(i).AttackPotential1 + ") ");

            AttackTrees1111.Controls.Add(tv);
            tv.Nodes.Add(root);


        }
        //populateTreeview();
    }

enter image description here As you can see multiple tree views are on screen but only 1 root node shows and that is from the first loop when i=0, my goal is to show different rood node for each treeview. How can I achieve that?

0

There are 0 answers