Reputation: 1
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
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