Click to See Complete Forum and Search --> : Help moving/copying nodes between 2 treeViews


auutumn
February 11th, 2010, 11:04 AM
In my C# 2008 application, I have two treeview controls and Add, AddAll, Remove, and RemoveAll buttons. When the application starts, a populate() method is called which reads in the files in a specified directory and populate treeView1 which looks like this:

Billing
|---cBilling1
|---cBilling2
Home
|---cHome
Login
|---cLogin1
|---cLogin2

The user can copy/move a parent and all children or just a child between treeViews. The code is intelligent enough (almost) to know how to copy/move parents and children around so that the structure of both treeViews remains intact.

The issue I have is after I copy a child from treeView1 to treeView2 and then try to move that child back to treeView1, the child is put with the wrong parent. Below is the scenario.

Scenario #1:
1. Click on cBilling1 in treeView1.
2. Click the Add button
3. Click on cBilling1 in treeview2.
4. Click Remove.
-- cBilling1 is placed under the wrong parent.

The populate() method expects a folder the following folder structure and files in them (which can be empty).

C:\QA\Testscripts\Billing\cBilling1.py
C:\QA\Testscripts\Billing\cBilling2.py
C:\QA\Testscripts\Home\cHome.py
C:\QA\Testscripts\Login\cLogin.1py
C:\QA\Testscripts\Login\cLogin2.py

I appreciate any and all help!

memeloo
February 11th, 2010, 11:37 AM
it seems to work fine. only the Login node is being splitted when I move everything to the right and then back to the left.

auutumn
February 11th, 2010, 01:49 PM
I tried several scenarios and I still find there are a few issues such as:

Scenario #1:
1. Click Add All
2. Select cWater then click Remove
3. Select cLogin then click Remove -- cLogin is now a child of Water instead of Login.

Scenario #2:
1. Click on either cHome/cLogin/cWater then Add
2. Click on either cBilling1/cBilling2 then Add -- cBilling1/cBilling2 is add under the wrong parent

Out of curiosity, does your treeView look like mine? I don't know if it matters but I'm trying to make sure everything looks the same. I can send you a screen shot of what the above scenarios look like if you want.

memeloo
February 11th, 2010, 02:18 PM
after starting the app the tree on the left looks like this:

Billing
|---cBilling1
|---cBilling2
Home
|---cHome
Login
|---cLogin1
Login
|---cLogin2

auutumn
February 11th, 2010, 07:39 PM
Thx for catching that issue; I also tidied up a few other things such as commenting out the two treeview sort methods in the DeleteNode method. I'm still getting some issues when I try to add and remove children around. I've attached the updated version of the program.