How can I rename a node in TreeView?
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.
精彩评论