treeview question

Mookie_jones

Member
Joined
Oct 23, 2005
Messages
16
Programming Experience
Beginner
i am trying to create a treeview that is going to be used as a text editor.


when the word ";fold" appears, a new child should be created and nodes will be added until the word ";endfold" appears on another line. here is the code i have for it but it is incorrect and im not sure what im doing wrong.


Dim fold As New TreeNode("fold")
Dim item As Collection
fold.Nodes.Add("")
Dim onenode As String
Dim i As Integer
For i = 1 To foldinfo.Count - 1
fold.Nodes.Add(New TreeNode(foldinfo.Item(i)))
rtbbottom.Nodes.AddRange(foldinfo.Item(i))
Next

End Function
Private Sub rtbTop_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtbTop.TextChanged
Dim i As Integer
Dim Foldinfo As New Collection
rtbbottom.Nodes.Clear()
Dim temp() As String
For i = 0 To rtbTop.Lines.Length - 1
If InStr(UCase(rtbTop.Lines(i)), ";FOLD") Then
Dim ttest As New TreeNode
temp = Split(UCase(rtbTop.Lines(i)), ";FOLD")
Foldinfo.Add(temp(0))
keep:

i = i + 1
If InStr(UCase(rtbTop.Lines(i)), ";ENDFOLD") Then
Foldinfo.Add("")
addnewfold(Foldinfo)
Else
Foldinfo.Add(rtbTop.Lines(i))
End If
GoTo keep
Else
If InStr(rtbTop.Lines(i), ";endfold") Then
Debug.Write("hi")
Else
rtbbottom.Nodes.Add(rtbTop.Lines(i))
End If
End If
Next
End Sub
 
:bump


i guess what would help me is jsut to know how to add and new nodes to the form. i have tried to look some things up but it uses treeview1.selectednode.nodes.add

when i run this, i end up with an error because there isnt a node selected due to they are added programattically.

example:


fold
info
info
endfold

move
move
io
fold
info
endfold
 
Back
Top