I try to read all checked nodes. It works, if I have only root nodes. But now I try to work with root and child nodes. But I only can set and read the childs as TreeItem instead of CheckBoxTreeItem. Perhaps someone can halp ?
B4X:
If bFill = True Then
objTreeQKoerper.SetCheckBoxesMode
If sZW(2) = "P" Then
Dim cti As CheckboxTreeItem
cti.Initialize("ti", sZW(0))
objTreeQKoerper.Root.Children.Add(cti)
Else
Dim ti As TreeItem ' CheckBoxTreeItem not possible
ti.Initialize("ti", sZW(0))
cti.Children.Add(ti)
End If
End If
B4X:
For Each tn As CheckboxTreeItem In objTreeQKoerper.Root.Children
Log(tn.Text)
For i = 0 To tn.Children.Size - 1
Dim tc As TreeItem ' CheckBoxTreeItem not possible
tc = tn.Children.Get(i)
Log(tc.Text)
Next
Next
For Each O As Object In objTreeQKoerper.Root.Children
If O Is CheckBoxTreeItem Then
Dim tc As CheckBoxTreeItem = O
Log(tc.Text)
Else
Dim ti As TreeItem = O
Log(ti.Text)
End If
Next
Next
Thank you. But it displays only the root nodes. A have to set and read the checked property inside a loop. I think the childs only hava a checkbox because the whole tree is set to SetCheckBoxesMode. But on creating the childs I can't define it as checkboxnodes.
Only for info - Before I look after TreeTableView I did it on my own way (your "For Each O As Object" was the key). So I have the functionality I need.
B4X:
Dim iEntries As Int = 0
Dim iResonanzen As Int = 0
For Each O As Object In objTreeQKoerper.Root.Children
iEntries = iEntries + 1
Dim ti As TreeItem = O
ti.Image = treeblank .GetImage
If fCheckEntry = True Then
ti.Image = treeres .GetImage
iResonanzen = iResonanzen + 1
End If
Dim ti2 As TreeItem
ti2 = ti
For i = 0 To ti2.Children.Size - 1
iEntries = iEntries + 1
Dim trItemChild As TreeItem
trItemChild = ti2.Children.Get(i)
trItemChild.Image = treeblank .GetImage
If fCheckEntry = True Then
trItemChild.Image = treeres .GetImage
iResonanzen = iResonanzen + 1
End If
Next
Next
lblResonanzenQKoerper.Text = iResonanzen & " / " & iEntries