New a TreeView tV1
private void tV1_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode tvNode=new TreeNode();
tvNode=tV1.SelectedNode;
button1.Text = tvNode.Text;
}
private void btnRoot_Click(object sender, EventArgs e)
{
foreach (string item in listBox1.Items)
{
tV1.Nodes.Add(item);
}
this.tV1.SelectedNode = this.tV1.Nodes[this.tV1.Nodes.Count - 1];
tV1.LabelEdit = true;
if (!this.tV1.SelectedNode.IsEditing)
{
this.tV1.SelectedNode.BeginEdit();
}
}
private void btnChild_Click(object sender, EventArgs e)
{
TreeNode tvNode = new TreeNode();
tvNode = tV1.SelectedNode;
foreach (string item in listBox1.Items)
{
tvNode.Nodes.Add(item);
}
}