Tree-view hierarchie

This is a discussion on "Tree-view hierarchie" within the ASP.NET Forum section. This forum, and the thread "Tree-view hierarchie are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > ASP.NET Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 15th, 2007, 14:25
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Tree-view hierarchie

.NET 2.0 using VS2005

I'm trying to get this tree-view working properly.

Here's the directory structure on my c: in a specific folder

Code: Select all
- Active
- Archive
  |
  |-- 04-05
  |-- 05-06
  |-- 06-07
Here's my code right now.

Code: Select all
For Each _d As String In Directory.GetDirectories("C:\Change Request\")

            Dim _folder As String = _d.Substring(_d.LastIndexOf("\") + 1)
            tvListFolders.Nodes.Add(_folder)

            Dim ThisDirectory As String = _folder

            For Each _dd As String In Directory.GetDirectories("C:\Change Request\" & ThisDirectory)

                Dim _dfolder As String = _dd.Substring(_dd.LastIndexOf("\") + 1)
                tvListFolders.Nodes.Add(_dfolder)

            Next

        Next
And this is what display (see attachment) ... Now ... how do I get the 04-05, 05-06 and 06-07 folder moved under the Archived folder? instead of under "root"?

I would've thought the second for loop in there would give me that but .... obviously that didn't work. I think I need to assign something as parent but ... I'm new at .NET so ... explanation and help would be greatly appreciated.

Thanks
Attached Images
File Type: jpg tree-view.jpg (28.4 KB, 48 views)
Reply With Quote

  #2 (permalink)  
Old Jan 16th, 2007, 14:43
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Tree-view hierarchie

I figure it out.... here's the code that works

Code: Select all
For Each _d As String In Directory.GetDirectories(txtPath.Text)

            Dim _folder As String = _d.Substring(_d.LastIndexOf("\") + 1)
            Dim parentNode As TreeNode = New TreeNode(_folder)

            For Each _dd As String In Directory.GetDirectories(txtPath.Text & "\" & _folder)

                Dim _dfolder As String = _dd.Substring(_dd.LastIndexOf("\") + 1)
                Dim childNode As TreeNode = New TreeNode(_dfolder)
                'parentNode.ChildNodes.Add(childNode)
                parentNode.Nodes.Add(childNode)

            Next

            tvListFolders.Nodes.Add(parentNode)
        Next
Reply With Quote
Reply

Tags
net 20, treeview

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with tree menu mcnika JavaScript Forum 1 May 22nd, 2008 13:13
HTML_TreeMenu and Tree simonneaves PHP Forum 2 Nov 11th, 2007 09:27
Zoomable Tree jerols Free Web Site Critique 4 May 9th, 2007 12:49
TREE-view disply problem sreenivas2k Classic ASP 0 Jul 19th, 2006 09:37
Tree view k_narend Classic ASP 2 Aug 23rd, 2005 11:56


All times are GMT. The time now is 00:03.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43