Ji-yong Kim
Ji-yong Kim

Reputation: 1

what code is make to treeview node expand

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?

Upvotes: 0

Views: 67

Answers (1)

Jim
Jim

Reputation: 2984

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();
        }
    }
}

Upvotes: 1

Related Questions