B4J Question how to generate checkbox only for father in treeview

bvonlaar

Member
Licensed User
Longtime User
Hi all,
I want to generate a checkbox only for the 1. root of a treeview. The childs shouldn´t have a checkbox.
Is it possible? If yes, how?

Thank´s
Benedikt
 

Daestrum

Expert
Licensed User
Longtime User
do you mean this effect ?
treeview checks.png
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Example code of how I did it, should be easy to modify. (It uses javaobject library)
B4X:
.... 
 Dim treev As TreeView
 treev.Initialize("treev")
 For a = 1 To 5
 Dim cbi As JavaObject
 Dim cb As CheckBox
 cb.Initialize("")
 cbi.InitializeNewInstance("javafx.scene.control.TreeItem",Array("parent "&a,cb))
 treev.Root.Children.Add(cbi)
 For b = 1 To 5
 Dim ti As TreeItem
 ti.Initialize("","child "&b)
 asTI(cbi).Children.Add(ti)
 Next
 Next
 MainForm.RootPane.AddNode(treev,0,0,-1,-1)
End Sub
Sub asTI(o As TreeItem) As TreeItem
 Return o
End Sub
Sub asJO(o As JavaObject)As JavaObject
 Return o
End Sub
Sub treev_SelectedItemChanged(SelectedItem As TreeItem)
 Log(SelectedItem)
 Try 
 Log("checkbox is "&asJO(SelectedItem).RunMethodJO("getGraphic",Null).RunMethod("isSelected",Null))
 Catch
 End Try 
End Sub
 
Upvote 0

bvonlaar

Member
Licensed User
Longtime User
Much thanks Daestrum,
I try to become familiar with this, but it looks like I´m looking for. It seems to be an interest alternative to the standard treeview.
In my case parent will be a switchable Layer and the childs are for controlling properties of the Layer.

Benedikt
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
The treeview is very flexible, I have one which has tableviews for child items.
You can put any type of node in a treeview ( or two nodes - one will be its value, and the other the graphic).
 
Upvote 0

bvonlaar

Member
Licensed User
Longtime User
The treeview is very flexible, I have one which has tableviews for child items.
You can put any type of node in a treeview ( or two nodes - one will be its value, and the other the graphic).

Sounds interest. For the moment I´m happy that it works as needed.
I think it´s also possible to connect the tableviews with a SQLLite table? But this would be another App :).

Benedikt
 
Upvote 0
Top