Results 1 to 3 of 3

Thread: Populate TreeView from text file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Posts
    104

    Lightbulb Populate TreeView from text file

    Hi,

    Just curious is it possible to populate a TreeView from a text file?
    VB.Net 2005

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Populate TreeView from text file

    You populate a TreeView with TreeNodes. Where the information that those nodes contains comes from is completely up to you. Their Text property is just a String, so you can assign whatever string you want.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    24

    Re: Populate TreeView from text file

    I made it the simple primitive way ,,, it did work properly
    ========================================
    Private Sub Form_Load()
    Dim variable1 As String
    Open "tree.txt" For Input As #1
    Do While Not EOF(1)
    Input #1, variable1
    sb = Split(variable1, "|")
    Select Case sb(0)
    Case "parent"
    Me.TreeView1.Nodes.Add , , sb(1), sb(1) 'the parent
    Case "child"
    Me.TreeView1.Nodes.Add sb(1), tvwChild, sb(2), sb(2) 'the child

    End Select
    Loop
    Close #1
    End Sub
    =====================
    in the text file arrange lines like this
    ============================
    parent|father-name
    child|father-name|son-name

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