Editing a TreeView node doesn't change the TreeNode Key
Posted
by Blitzz
on Stack Overflow
See other posts from Stack Overflow
or by Blitzz
Published on 2010-04-25T00:04:24Z
Indexed on
2010/04/25
0:13 UTC
Read the original article
Hit count: 237
I have a TreeView with user-editable nodes. I like to use the node caption as key to my tree node :
+ Root
|+ Node1
||- SubNode1
||- SubNode2
|+ Node2
||- SubNode3
||- SubNode4
So I can reach a node like this:
MyTreeView.Nodes["Root"].Nodes["Node2"].Nodes["SubNode3"]
The problem is that, as I allow the user to rename any node, I would need also to change the key of my node in its parent in the AfterLabelEdit handler... which seems (logically) not to be done automatically. Unfortunately, Nodes["blabla"] is readonly, Nodes.Add(string Key, TreeNode Node) doesn't exist, and I can't find a way to do this without throwing (sooner or later) a bad exception.
Any idea ?
© Stack Overflow or respective owner