开发者

Editing a TreeView node doesn't change the TreeNode Key

开发者 https://www.devze.com 2022-12-27 21:19 出处:网络
I have a TreeView with user-editable nodes. I like to use the node caption开发者_运维技巧 as key to my tree node :

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 ?


Well, changing the Node.Name property seems to work...

0

精彩评论

暂无评论...
验证码 换一张
取 消