Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating treeview with delimited strings

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
Hello, I would like some assistance reversing this subroutine I have already written for a custom tree component. Right now users could add sets with pictures/descriptions being child nodes of the set nodes. Whenever the tree is updated it generates a string property which is the delimited string that is stored in the MySQL database (I plan on using this as a clientside control to auto-generate the strings for the users on the publishing interfaces) , I wish to take this function and reverse it so that if I loaded a pre-existing gallery delimited string that the treeview could be populated from the saved information and allow for editing. Future thanks for any assistance provided.

Code:
Public Sub update_gallery()
Gal_Text = ""

For Each ObjNode In TreeView1.Nodes
    If ObjNode.Children > 0 Then
        If Gal_Text <> &quot;&quot; Then
            Gal_Text = Gal_Text & &quot;|&quot; & vbCrLf
        End If
        Set_str = &quot;&quot;
        N = ObjNode.Child.FirstSibling.Index
        Set_str = &quot;&quot;
        While N <> ObjNode.Child.LastSibling.Index
            If Set_str <> &quot;&quot; Then
                Set_str = Set_str & &quot;^&quot;
            End If
            Set_str = Set_str & Replace(TreeView1.Nodes(N).Text, &quot;,&quot;, &quot;#&quot;)
            N = TreeView1.Nodes(N).Next.Index
        Wend
        If Set_str <> &quot;&quot; Then
            Set_str = Set_str & &quot;^&quot;
        End If
        Gal_Code = Gal_Code & Set_str & Replace(TreeView1.Nodes(N).Text, &quot;,&quot;, &quot;#&quot;)
    End If
Next

End Sub

a better understanding of the string is as such.

Image#OptionalDescription^Image^Image^Image|Image^Image#optionaldescription^Image^Image|Image

where | seperates the sets
^ seperates each images in a set
and # seperates image from optional description (which is seperated by a comma in the tree as it shares a node)

Thanks again for any assistance. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
Found a &quot;Duh&quot; solution:

Code:
Public Sub update_tree(GText As String)
Dim skey As String
Dim oNodex As Node
Dim ikey As String
Dim iIndex As Integer
Gal_Text = GText
SetSplit = Split(GText, &quot;|&quot;)

For J = LBound(SetSplit) To UBound(SetSplit)
    skey = GetNextKey()
    If Not (TreeView1.SelectedItem Is Nothing) Then
        TreeView1.Nodes.Add TreeView1.SelectedItem.Index, tvwLast, skey, &quot;+&quot;
    Else
        TreeView1.Nodes.Add , tvwLast, skey, &quot;+&quot;
    End If
    
    ImageSplit = Split(SetSplit(J), &quot;^&quot;)
    For i = LBound(ImageSplit) To UBound(ImageSplit)
        TempGal = Replace(ImageSplit(i), &quot;#&quot;, &quot;,&quot;)
        ikey = GetNextKey()
        Set oNodex = TreeView1.Nodes.Add(skey, tvwChild, ikey, TempGal)
        oNodex.EnsureVisible
    Next i
Next J

RaiseEvent GalTextUpdated(Gal_Text)

End Sub
Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top