Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I am having a treeview as follows:
http://lh6.ggpht.com/_3_c9olh5X7s/THixEj1Lj9I/AAAAAAAADls/8cJnq33Ksso/s800/8-28-2010%2012-16-14%20PM.png

If i right click on the files which are named as .txt i will have an option like rename if user selects that i would like to do the following things:

1. Displaying dialog to prompt for the name.
2. Changing the text of the node in the TreeView control.
3. Replacing the old file with the current file name in the path
Posted
Updated 29-Aug-10 23:15pm
v2

1 solution

well set the treeview's property as

treeView1.LabelEdit = true;

that will allow you to edit the node text easily. then you can handle the event "BeforeLabelEdit" to validate the new name of the file and change the file name (I would just copy the file to the new name and delete the existing one, am just lazy :) ). To validate the new file name you can use

System.IO.Path.GetInvalidFileNameChars()

to obtain list of illegal characters.

Hope this helps, good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900