A
Adam Klobukowski
Hello
I'm trying to implement 'in place' node adding to treeview. Ie, user
requests new item and it appears in treeview reade to edit.
I have this C# code:
if (treeView1.SelectedNode != null)
{
TreeNode node = treeView1.SelectedNode;
node.Nodes.Add("");
node.Expand();
node.Nodes[node.Nodes.Count - 1].EnsureVisible();
treeView1.LabelEdit = true;
node.Nodes[node.Nodes.Count - 1].BeginEdit();
}
It works well if a node I'm adding subnode already has some nodes. It
does not work if node I'm adding subnode has no subnodes yet: after
node.Expand(), node.Nodes is empty (ie node.Nodes.Count == 0).
What is wrong here?
I'm trying to implement 'in place' node adding to treeview. Ie, user
requests new item and it appears in treeview reade to edit.
I have this C# code:
if (treeView1.SelectedNode != null)
{
TreeNode node = treeView1.SelectedNode;
node.Nodes.Add("");
node.Expand();
node.Nodes[node.Nodes.Count - 1].EnsureVisible();
treeView1.LabelEdit = true;
node.Nodes[node.Nodes.Count - 1].BeginEdit();
}
It works well if a node I'm adding subnode already has some nodes. It
does not work if node I'm adding subnode has no subnodes yet: after
node.Expand(), node.Nodes is empty (ie node.Nodes.Count == 0).
What is wrong here?