Hi,
Just curious is it possible to populate a TreeView from a text file? :ehh:
Printable View
Hi,
Just curious is it possible to populate a TreeView from a text file? :ehh:
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.
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