开发者

Changing the node value of treeview

Hi all i have written a code to move a file from the original path to the new path this was working fine.

Initially my treeview will have a root node and i am adding child nodes at the run time. My tree is as follows

        Root
          |->C:\some.txt(Assume that it is in c drive)

Now if i right click on that i will have a context menu with options Move and some other. If i select move i will ask the user for changing the path. If the user selects a path i am moving the file to the selected destination. Now what i need is i would like to replace the current child of the treeview with the new pat开发者_开发技巧h.

Like initially mt file was in c: if i moved it to D:

I should have my tree as

          Root
            |->D:\some.txt


Add a member variable to your form as:

private Point location; 

Add a handler to the MouseDown event on the TreeView as:

private void treeView1_MouseDown(object sender, MouseEventArgs e)
{
    location = e.Location;
}

In the event handler for the move menu click event do something like:

TreeViewHitTestInfo info =  treeView1.HitTest(location);
info.Node.Text = "new path";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜