开发者

How can I rename a node in TreeView?

开发者 https://www.devze.com 2023-01-30 07:45 出处:网络
I used a TreeView in my WinForms application. In this application, I add a node to the TreeView. Now I want to rename (not to change text) a node. In other words, I want to change the nam开发者_开发技

I used a TreeView in my WinForms application.

In this application, I add a node to the TreeView. Now I want to rename (not to change text) a node. In other words, I want to change the nam开发者_开发技巧e property of a new node.

Please tell me how I can do this. Thanks.


I suspect that it's simpler than you think. Each TreeNode item exposes a Name property that allows you to get or set the name of that particular node.

So, to change the name of the currently selected node in your TreeView, all you have to do is set its Name property to a new string value. For example:

myTreeView.SelectedNode.Name = "NewNodeName";

As you've asked, this will not affect the text that is displayed for that particular node. If you want to change that, you can set the node's Text property.

0

精彩评论

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