CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2010
    Posts
    3

    Help moving/copying nodes between 2 treeViews

    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!
    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Help moving/copying nodes between 2 treeViews

    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.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  3. #3
    Join Date
    Feb 2010
    Posts
    3

    Re: Help moving/copying nodes between 2 treeViews

    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.

  4. #4
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Help moving/copying nodes between 2 treeViews

    after starting the app the tree on the left looks like this:

    Billing
    |---cBilling1
    |---cBilling2
    Home
    |---cHome
    Login
    |---cLogin1
    Login
    |---cLogin2
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  5. #5
    Join Date
    Feb 2010
    Posts
    3

    Re: Help moving/copying nodes between 2 treeViews

    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.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured