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?

--
Semper Fidelis

Adam Klobukowski
atari@gabo.pl

Re: TreeView expand problem by Adam

Adam
Tue Mar 15 04:15:44 CST 2005

As usual, after sending this question, I found that my function in
BeforeExpand was causing this.

--
Semper Fidelis

Adam Klobukowski
atari@gabo.pl