views:

27

answers:

1

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 path.

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

I should have my tree as

          Root
            |->D:\some.txt
+1  A: 

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";
ho1
Thanks a Lot :)
Dorababu