Android Question Hello, I use Clvtree. I want to show the father's name when you press the last son

alfaiz678

Active Member
Licensed User
Hello, I am using CLVTree. I want to display the father’s name when clicking on the last son

as in the picture
when clicking on item 3
I want to display the names of the highest fathers in a message, for example
i.e. the names of item 1 and item 2 appear

1686590965692.png
 
Solution
i.e. the names of item 1 and item 2 appear
Based on the screenshot you have posted, the itemclick event should be something like this if you click on titem 3:
B4X:
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Dim item As CLVTreeItem = Value    
    Log("Item 3 (son) " & item.Text)  'displays item 3
    Log("Item 2 (father) " & item.Parent.Text)   'displays item 2
    Log("Item 1 (grand father) " & item.Parent.Parent.text)   'displays item 1
End Sub
However, if you want to be able to click on any level, not just 3 to avoid a crash, you need to involve the Item.tag. to differentiate between the levels If you need help with that, come back.

epiCode

Active Member
Licensed User
clvTree uses custom type called CLVTreeItem which has a parameter "Parent" which returns yet another clvTreeItem which is its parent.
You can easily backtrack using the same until you reach the root of hierarchy (meaning no more parent available).
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
i.e. the names of item 1 and item 2 appear
Based on the screenshot you have posted, the itemclick event should be something like this if you click on titem 3:
B4X:
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Dim item As CLVTreeItem = Value    
    Log("Item 3 (son) " & item.Text)  'displays item 3
    Log("Item 2 (father) " & item.Parent.Text)   'displays item 2
    Log("Item 1 (grand father) " & item.Parent.Parent.text)   'displays item 1
End Sub
However, if you want to be able to click on any level, not just 3 to avoid a crash, you need to involve the Item.tag. to differentiate between the levels If you need help with that, come back.
 
Last edited:
Upvote 1
Solution

alfaiz678

Active Member
Licensed User
Based on the screenshot you have posted, the itemclick event should be something like this if you click on titem 3:
B4X:
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Dim item As CLVTreeItem = Value   
    Log("Item 3 (son) " & item.Text)  'displays item 3
    Log("Item 2 (father) " & item.Parent.Text)   'displays item 2
    Log("Item 1 (grand father) " & item.Parent.Parent.text)   'displays item 1
End Sub
However, if you want to be able to click on any level, not just 3 to avoid a crash, you need to involve the Item.tag. to differentiate between the levels If you need help with that, come back.
Thank you
I can do with the code what I want now
 
Upvote 0
Top