Solved

tree childnode

Posted on 2013-02-05
3
259 Views
Last Modified: 2013-02-06
For some reason I can only choose the first child node but not the rest.
for example I have 3 childnode folders and they are listed by date. But when I try to change the second and third child node I cannot. I try to split the string and yet I still cannot.  Only the first ChildNode it picks up and skips the rest.


 For Each subDir As DirectoryInfo In subDirs
            Dim d As DateTime
            Dim provider As IFormatProvider = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat
            If (DateTime.TryParseExact(subDir.ToString, "MMddyyyy", provider, DateTimeStyles.None, d)) Then
                Dim subDir2 As String = d.ToString("MMMM dd, yyyy")
                Dim s As String = subDir2 & "~"
                Dim words = s.Split(New Char() {"~"c})
                thisDirNode.ChildNodes.Add(RecurseNodes(subDir))
                For Each word In words
                    thisDirNode.ChildNodes(0).Text = subDir2.ToString
                Next word
           
            End If
0
Comment
Question by:sevensnake77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
AshwaniMunshi earned 500 total points
ID: 38858943
Please refer the example below and see if it can help you:

For Each subtree As DirectoryInfo In directory.GetDirectories()
Dim subNode As New TreeNode(subtree.Name)
subNode.Value = subtree.FullName
Try
If subtree.GetDirectories().Length > 0 Or subtree.GetFiles().Length > 0 Then
subNode.SelectAction = TreeNodeSelectAction.SelectExpand
subNode.PopulateOnDemand = True
subNode.NavigateUrl = "#"
End If
Catch ex As Exception

End Try
node.ChildNodes.Add(subNode)
Next subtree
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 38859992
Ok I see the problem . the above code did not work. when I am trying to rename each childnode by date it only writes the last one to the first node.

in my response.write i get.
January 02, 2013January 08, 2013February 05, 2013

but in my nodes I only get the last date which shows up in folder 01022013

how can I get the dates to show on all 3 folders.

 For Each subDir As DirectoryInfo In thisDir.GetDirectories()
           
            If (DateTime.TryParseExact(subDir.ToString, "MMddyyyy", provider, DateTimeStyles.None, d)) Then
                Dim subDir2 As String = d.ToString("MMMM dd, yyyy")
              
                Dim subNode As New TreeNode(thisDir.Name)
                subNode.Value = thisDir.FullName

                If subDir.GetDirectories().Length > 0 Or subDir.GetFiles().Length > 0 Then
                    '       For Each word In words
                    Dim s As String = subDir2 & "~"
                    Dim words = s.Split(New Char() {"~"c})
                    thisDirNode.ChildNodes.Add(RecurseNodes(subDir))
                    thisDirNode.ChildNodes(0).Text = subDir2.ToString
                    Response.Write(subDir2)
                End If

Open in new window

ScreenHunter-07-Feb.-06-10.45.jpg
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 38861343
I had to add a count on the page load not in the fucntion and it seem to work. Thanks for participating.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question