Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Tree view delete

Tree view delete

Scheduled Pinned Locked Moved C#
csharpdata-structureshelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chandler83
    wrote on last edited by
    #1

    Hi, i have a folder view which list all my folders in a tree view form. My requirement is, after selecting a folder if i send a delete command it has to delete all folders and its contents. Problem is only after deleting the files in the subfolders,i can delete the folder. i need to do an recursive search. Urgent.... plzzzzzzzz reply. I am using c# windows application. e.g 1 11 12 121 122 13 say my tree view looks like this... if i delete the folder 1. it should find out all the subfolders. Should delete 13 first and 122 and then 121 and 12 and 11. plzzzzzzz do guide me... Thanks in advance...:((

    B 1 Reply Last reply
    0
    • C chandler83

      Hi, i have a folder view which list all my folders in a tree view form. My requirement is, after selecting a folder if i send a delete command it has to delete all folders and its contents. Problem is only after deleting the files in the subfolders,i can delete the folder. i need to do an recursive search. Urgent.... plzzzzzzzz reply. I am using c# windows application. e.g 1 11 12 121 122 13 say my tree view looks like this... if i delete the folder 1. it should find out all the subfolders. Should delete 13 first and 122 and then 121 and 12 and 11. plzzzzzzz do guide me... Thanks in advance...:((

      B Offline
      B Offline
      BoneSoft
      wrote on last edited by
      #2

      private void DeleteStuff(TreeNode root) {
      // If you have children, process them first
      foreach (TreeNode tn in root.Nodes) {
      DeleteStuff(tn);
      }
      // Delete files
      }


      Try code model generation tools at BoneSoft.com.

      C 1 Reply Last reply
      0
      • B BoneSoft

        private void DeleteStuff(TreeNode root) {
        // If you have children, process them first
        foreach (TreeNode tn in root.Nodes) {
        DeleteStuff(tn);
        }
        // Delete files
        }


        Try code model generation tools at BoneSoft.com.

        C Offline
        C Offline
        chandler83
        wrote on last edited by
        #3

        :doh:hi i did but then its not working properly..... if i select a node. the rootnode.nodes property is not taking the subfolders of the child node.... 1 11 12 13 131 132 14 in the above the 131 and 132 nodes are not accecible.... they r not coming under the collectios..... plzzzzzzzz help me.. thanks a lot in advance......cheers.

        B 1 Reply Last reply
        0
        • C chandler83

          :doh:hi i did but then its not working properly..... if i select a node. the rootnode.nodes property is not taking the subfolders of the child node.... 1 11 12 13 131 132 14 in the above the 131 and 132 nodes are not accecible.... they r not coming under the collectios..... plzzzzzzzz help me.. thanks a lot in advance......cheers.

          B Offline
          B Offline
          BoneSoft
          wrote on last edited by
          #4

          If you use the method above, and pass it node '13', it will process '131' and '132' before doing 13. You're not using the treeView.Nodes are you? What ever owns the 1, 11, 12, 13 & 14 nodes (treeView or another node) won't have 131 and 132 in it's Nodes collection, node 13 will. A TreeNode object has a Nodes colleciton just as TreeView does. That's why the method above accepts a TreeNode, and pocesses it's children before itself. Maybe I don't fully understand you question.


          Try code model generation tools at BoneSoft.com.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups