B4J Question TreeView reset


Licensed User

I fill a TreeView. Dependent on option fields with different values. So I need to clear the TreeView and fill it with other values.

If I try objTree.RemoveNodeFromParent the whole component dissapears.

Then I thought I make different root entrys and made it this way below. But the version with clearing the tree I would prefered.

Perhaps anybody can give me a tip ?

Thanks a lot !

    Dim ti As TreeItem
    ti.Initialize("ti", "Mann")
    Dim ti2 As TreeItem
    ti2.Initialize("ti2", "Frau")
    Dim ti3 As TreeItem
    ti3.Initialize("ti3", "Hund")
    Dim ti4 As TreeItem
    ti4.Initialize("ti4", "Katze")
    Dim ti5 As TreeItem
    ti5.Initialize("ti5", "Pferd")

    Dim iCount As Int
    iCount = 0
    For Each n As String In arrAnatomie
        Dim sTemp As String

        sTemp = arrAnatomie(iCount)
        Dim sZW() As String
        sZW = Regex.Split(",",sTemp)

        If sZW(2) = "B" Or sZW(2) = "M" Then
            Dim cti As TreeItem
            cti.Initialize("ti", sZW(0))
            ti.Children.Add(cti) 'add the child
        End If

        If sZW(2) = "B" Or sZW(2) = "F" Then
            Dim cti As TreeItem
            cti.Initialize("ti2", sZW(0))
            ti2.Children.Add(cti) 'add the child
        End If

        iCount = iCount + 1
    objTreeAnatomie.Root.Children.Add(ti) 'add the father to the root
    objTreeAnatomie.Root.Children.Add(ti2) 'add the father to the root