B4J Question treeview, get checked nodes

MichaelF

New Member
I have a TreeView with the option SetCheckBoxesMode with only root nodes.

I want to run through all nodes and get the text of the checked one. I would be happy for help!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I have a TreeView with the option SetCheckBoxesMode with only root nodes.
Sounds like a mistake. If you want to create a list then xCLV is the best option.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    TreeView1.SetCheckBoxesMode
    For i = 1 To 10
        Dim tn As CheckboxTreeItem
        tn.Initialize("", i)
        TreeView1.Root.Children.Add(tn)
    Next
End Sub


Private Sub Button1_Click
    For Each tn As CheckboxTreeItem In TreeView1.Root.Children
        If tn.Checked Then
            Log(tn.Text)    
        End If
    Next
End Sub
 
Upvote 0
Top