0

enter image description here

private void Form1_Load(object sender, EventArgs e)
{   
    foreach (DriveInfo drv in DriveInfo.GetDrives())
    {
        if (drv.IsReady)
        {
            TreeNode t2 = new TreeNode();
            t2.Text = drv.Name;
            t2.Nodes.Add("");
            treeView.Nodes.Add(t2);
        }
    }
}

parent node don't expand to child node how can i fix it?

Jim
  • 2,974
  • 2
  • 19
  • 29
  • 5
    Possible duplicate of [How can I get all expanded nodes in treeview?](http://stackoverflow.com/questions/14596723/how-can-i-get-all-expanded-nodes-in-treeview) – Prisoner Nov 01 '16 at 01:30

1 Answers1

1

If you want to expand all nodes you can use the TreeView.ExpandAll() method

private void Form1_Load(object sender, EventArgs e)
{   
    foreach (DriveInfo drv in DriveInfo.GetDrives())
    {
        if (drv.IsReady)
        {
            TreeNode t2 = new TreeNode();
            t2.Text = drv.Name;
            t2.Nodes.Add("make this not empty to show a result");
            treeView.Nodes.Add(t2);

            treeView.ExpandAll();
        }
    }
}
Jim
  • 2,974
  • 2
  • 19
  • 29